Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_parsing():
assert setupmeta.to_int(None) is None
assert setupmeta.to_int(None, default=2) == 2
assert setupmeta.to_int("") is None
assert setupmeta.to_int("foo") is None
assert setupmeta.to_int(["foo"]) is None
assert setupmeta.to_int([1]) is None
assert setupmeta.to_int(1, default=2) == 1
assert setupmeta.to_int(0, default=2) == 0
def test_parsing():
assert setupmeta.to_int(None) is None
assert setupmeta.to_int(None, default=2) == 2
assert setupmeta.to_int("") is None
assert setupmeta.to_int("foo") is None
assert setupmeta.to_int(["foo"]) is None
assert setupmeta.to_int([1]) is None
assert setupmeta.to_int(1, default=2) == 1
assert setupmeta.to_int(0, default=2) == 0
def test_parsing():
assert setupmeta.to_int(None) is None
assert setupmeta.to_int(None, default=2) == 2
assert setupmeta.to_int("") is None
assert setupmeta.to_int("foo") is None
assert setupmeta.to_int(["foo"]) is None
assert setupmeta.to_int([1]) is None
assert setupmeta.to_int(1, default=2) == 1
assert setupmeta.to_int(0, default=2) == 0
def test_parsing():
assert setupmeta.to_int(None) is None
assert setupmeta.to_int(None, default=2) == 2
assert setupmeta.to_int("") is None
assert setupmeta.to_int("foo") is None
assert setupmeta.to_int(["foo"]) is None
assert setupmeta.to_int([1]) is None
assert setupmeta.to_int(1, default=2) == 1
assert setupmeta.to_int(0, default=2) == 0
def update_sources(self, next_version, commit, push, vdefs):
modified = []
for vdef in vdefs.sources:
if ".py:" not in vdef.source:
continue
relative_path, _, target_line = vdef.source.partition(":")
full_path = setupmeta.project_path(relative_path)
target_line = setupmeta.to_int(target_line, default=0)
lines = []
changed = 0
line_number = 0
revised = None
with io.open(full_path, "rt") as fh:
for line in fh.readlines():
line_number += 1
if line_number == target_line:
revised = updated_line(line, next_version, vdef)
if revised and revised != line:
changed += 1
line = revised
lines.append(line)
def run(self):
if not self.setupmeta:
return
if self.expand:
return self.show_expanded_python()
if self.dependencies:
return self.show_dependencies()
self.chars = setupmeta.to_int(self.chars, default=setupmeta.Console.columns())
definitions = self.setupmeta.definitions
self.check_recommend("name")
self.check_recommend("version", "you can use setupmeta's versioning='...'")
self.check_recommend("description", "add a README or a docstring to your module")
self.check_recommend("long_description", "add a README file")
if self.recommend:
self.check_recommend("author")
self.check_recommend("classifiers")
self.check_recommend("download_url")
self.check_recommend("license")
self.check_recommend("url")
if definitions:
longest_key = min(30, max(len(key) for key in definitions))
sources = sum((d.sources for d in definitions.values()), [])
def rendered_attr_auto_bumped(self, version):
"""
:param Version version: Version to render
:return str: Auto-bumped if possible
"""
value = self.rendered_attr(version)
return setupmeta.to_int(value) + 1