Skip to content

Commit 821152c

Browse files
committed
New distribution [0.7.3.post2]
* no changes to core logics * revised core codes
1 parent 1ac8a77 commit 821152c

5 files changed

Lines changed: 47 additions & 27 deletions

File tree

docker/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# basic info
22
FROM library/ubuntu
3-
LABEL version 0.7.3.post1
3+
LABEL version 0.7.3.post2
44
LABEL description "Ubuntu Environment for F2FORMAT"
55

66
# prepare environment

f2format.py

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
del multiprocessing
3232

3333
# version string
34-
__version__ = '0.7.3.post1'
34+
__version__ = '0.7.3.post2'
3535

3636
# from configparser
3737
BOOLEAN_STATES = {'1': True, '0': False,
@@ -357,6 +357,45 @@ def get_parser():
357357
return parser
358358

359359

360+
def find(root): # pragma: no cover
361+
"""Recursively find all files under root.
362+
363+
Args:
364+
- root -- os.PathLike, root path to search
365+
366+
Returns:
367+
- typing.Generator -- yield all files under the root path
368+
369+
"""
370+
flst = list()
371+
temp = os.listdir(root)
372+
for file in temp:
373+
path = os.path.join(root, file)
374+
if os.path.isdir(path):
375+
flst.extend(find(path))
376+
elif os.path.isfile(path):
377+
flst.append(path)
378+
elif os.path.islink(path): # exclude symbolic links
379+
continue
380+
yield from flst
381+
382+
383+
def rename(path, root):
384+
"""Rename file for archiving.
385+
386+
Args:
387+
- path -- os.PathLike, file to rename
388+
- root -- os.PathLike, archive path
389+
390+
Returns:
391+
- str -- the archiving path
392+
393+
"""
394+
stem, ext = os.path.splitext(path)
395+
name = '%s-%s%s' % (stem, uuid.uuid4(), ext)
396+
return os.path.join(root, name)
397+
398+
360399
def main(argv=None):
361400
"""Entry point for f2format.
362401
@@ -384,25 +423,6 @@ def main(argv=None):
384423
F2FORMAT_QUIET = os.getenv('F2FORMAT_QUIET')
385424
os.environ['F2FORMAT_QUIET'] = '1' if args.quiet else ('0' if F2FORMAT_QUIET is None else F2FORMAT_QUIET)
386425

387-
def find(root): # pragma: no cover
388-
"""Recursively find all files under root."""
389-
flst = list()
390-
temp = os.listdir(root)
391-
for file in temp:
392-
path = os.path.join(root, file)
393-
if os.path.isdir(path):
394-
flst.extend(find(path))
395-
elif os.path.isfile(path):
396-
flst.append(path)
397-
elif os.path.islink(path): # exclude symbolic links
398-
continue
399-
yield from flst
400-
401-
def rename(path):
402-
stem, ext = os.path.splitext(path)
403-
name = '%s-%s%s' % (stem, uuid.uuid4(), ext)
404-
return os.path.join(ARCHIVE, name)
405-
406426
# make archive directory
407427
if archive:
408428
os.makedirs(ARCHIVE, exist_ok=True)
@@ -412,13 +432,13 @@ def rename(path):
412432
for path in args.file:
413433
if os.path.isfile(path):
414434
if archive:
415-
dest = rename(path)
435+
dest = rename(path, root=ARCHIVE)
416436
os.makedirs(os.path.dirname(dest), exist_ok=True)
417437
shutil.copy(path, dest)
418438
filelist.append(path)
419439
if os.path.isdir(path):
420440
if archive:
421-
shutil.copytree(path, rename(path))
441+
shutil.copytree(path, rename(path, root=ARCHIVE))
422442
filelist.extend(find(path))
423443

424444
# check if file is Python source code

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
long_desc = file.read()
1616

1717
# version string
18-
__version__ = '0.7.3.post1'
18+
__version__ = '0.7.3.post2'
1919

2020
# set-up script for pip distribution
2121
setup(

share/f2format.1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
.\" Man page generated from reStructuredText.
22
.
3-
.TH F2FORMAT 1 "July 14, 2019" "v0.7.3.post1" ""
3+
.TH F2FORMAT 1 "July 21, 2019" "v0.7.3.post2" ""
44
.SH NAME
55
f2format \- back-port compiler for Python 3.6 f-string literals
66
.

share/f2format.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ f2format
66
back-port compiler for Python 3.6 f-string literals
77
---------------------------------------------------
88

9-
:Version: v0.7.3.post1
10-
:Date: July 14, 2019
9+
:Version: v0.7.3.post2
10+
:Date: July 21, 2019
1111
:Manual section: 1
1212
:Author:
1313
Jarry Shaw, a newbie programmer, is the author, owner and maintainer

0 commit comments

Comments
 (0)