Skip to content

Commit

Permalink
Blacken support files
Browse files Browse the repository at this point in the history
  • Loading branch information
acdha committed Jun 26, 2018
1 parent a389051 commit a3a8702
Show file tree
Hide file tree
Showing 3 changed files with 455 additions and 311 deletions.
33 changes: 20 additions & 13 deletions bench.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@

# fetch some images from NASA to bag up

if not os.path.isdir('bench-data'):
if not os.path.isdir("bench-data"):
print("fetching some images to bag up from nasa")
os.mkdir('bench-data')
ftp = ftplib.FTP('nssdcftp.gsfc.nasa.gov')
os.mkdir("bench-data")
ftp = ftplib.FTP("nssdcftp.gsfc.nasa.gov")
ftp.login()

ftp.cwd('/pub/misc/photo_gallery/hi-res/planetary/mars/')
ftp.cwd("/pub/misc/photo_gallery/hi-res/planetary/mars/")
files = []
ftp.retrlines('NLST', files.append)
ftp.retrlines("NLST", files.append)

for file in files:
print(("fetching %s" % file))
fh = open(os.path.join('bench-data', file), 'wb')
ftp.retrbinary('RETR %s' % file, fh.write)
fh = open(os.path.join("bench-data", file), "wb")
ftp.retrbinary("RETR %s" % file, fh.write)
fh.close()


Expand All @@ -48,13 +48,15 @@

for p in range(1, 9):
t = timeit.Timer(statement % p)
print(("create w/ %s processes: %.2f seconds " % (p, (10 * t.timeit(number=10) / 10))))
print(
("create w/ %s processes: %.2f seconds " % (p, (10 * t.timeit(number=10) / 10)))
)


# validate a bag with 1-8 processes

shutil.copytree('bench-data', 'bench-data-bag')
bagit.make_bag('bench-data-bag')
shutil.copytree("bench-data", "bench-data-bag")
bagit.make_bag("bench-data-bag")

# validate bench-data using n processes
statement = """
Expand All @@ -68,6 +70,11 @@
# try 1-8 parallel processes
for p in range(1, 9):
t = timeit.Timer(statement % p)
print(("validate w/ %s processes: %.2f seconds " % (p, (10 * t.timeit(number=10) / 10))))

shutil.rmtree('bench-data-bag')
print(
(
"validate w/ %s processes: %.2f seconds "
% (p, (10 * t.timeit(number=10) / 10))
)
)

shutil.rmtree("bench-data-bag")
70 changes: 38 additions & 32 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,68 +7,74 @@
import os
import subprocess
import sys
from setuptools import setup
from codecs import open

from setuptools import setup

if sys.version_info < (2, 7):
print("Python 2.7 or higher is required")
sys.exit(1)

description = 'Create and validate BagIt packages'
description = "Create and validate BagIt packages"

with open("README.rst", encoding="utf-8") as readme:
long_description = readme.read()

tests_require = ['mock', 'coverage']
tests_require = ["mock", "coverage"]


def get_message_catalogs():
message_catalogs = []

for po_file in glob.glob('locale/*/LC_MESSAGES/bagit-python.po'):
mo_file = po_file.replace('.po', '.mo')
for po_file in glob.glob("locale/*/LC_MESSAGES/bagit-python.po"):
mo_file = po_file.replace(".po", ".mo")

if not os.path.exists(mo_file) or os.path.getmtime(mo_file) < os.path.getmtime(po_file):
if not os.path.exists(mo_file) or os.path.getmtime(mo_file) < os.path.getmtime(
po_file
):
try:
subprocess.check_call(['msgfmt', '-o', mo_file, po_file])
subprocess.check_call(["msgfmt", "-o", mo_file, po_file])
except (OSError, subprocess.CalledProcessError) as exc:
print("Translation catalog %s could not be compiled (is gettext installed?) "
" — translations will not be available for this language: %s" % (po_file, exc),
file=sys.stderr)
print(
"Translation catalog %s could not be compiled (is gettext installed?) "
" — translations will not be available for this language: %s"
% (po_file, exc),
file=sys.stderr,
)
continue

message_catalogs.append((os.path.dirname(mo_file), (mo_file, )))
message_catalogs.append((os.path.dirname(mo_file), (mo_file,)))

return message_catalogs


setup(
name='bagit',
name="bagit",
use_scm_version=True,
url='https://libraryofcongress.github.io/bagit-python/',
author='Ed Summers',
author_email='[email protected]',
py_modules=['bagit', ],
scripts=['bagit.py'],
url="https://libraryofcongress.github.io/bagit-python/",
author="Ed Summers",
author_email="[email protected]",
py_modules=["bagit"],
scripts=["bagit.py"],
data_files=get_message_catalogs(),
description=description,
long_description=long_description,
platforms=['POSIX'],
test_suite='test',
setup_requires=['setuptools_scm'],
platforms=["POSIX"],
test_suite="test",
setup_requires=["setuptools_scm"],
tests_require=tests_require,
classifiers=[
'License :: Public Domain',
'Intended Audience :: Developers',
'Topic :: Communications :: File Sharing',
'Topic :: Software Development :: Libraries :: Python Modules',
'Topic :: System :: Filesystems',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3.1',
'Programming Language :: Python :: 3.2',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
"License :: Public Domain",
"Intended Audience :: Developers",
"Topic :: Communications :: File Sharing",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Filesystems",
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3.1",
"Programming Language :: Python :: 3.2",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
],
)
Loading

0 comments on commit a3a8702

Please sign in to comment.