@click.command(name="check-dir")
@click.argument("directory")
@click.option("-l", "--license", default="license-header.txt", help="License header file to compare against.")
-@click.option("-r", "--regex", default=".+\.py$", help="File regex pattern to match on when searching.")
+@click.option("-r", "--regex", default=r".+\.py$", help="File regex pattern to match on when searching.")
@click.pass_context
def check_directory(ctx, license, directory, regex):
"""Check directory for files missing license headers.
required=False,
help="Specify a file which contains a regexp expression to validate version number."
" File sample: "
- " ^\d+.\d+.\d+$ ",
+ r" ^\d+.\d+.\d+$ ",
)
@click.pass_context
def copy_from_nexus3_to_dockerhub(ctx, org, repo, exact, summary, verbose, copy, progbar, repofile, version_regexp):
continue
text += " {}".format(string)
# Strip unnecessary spacing
- text = re.sub("\s+", " ", text).strip()
+ text = re.sub(r"\s+", " ", text).strip()
return text
return 0
-def check_license_directory(license_file, directory, regex=".+\.py$"):
+def check_license_directory(license_file, directory, regex=r".+\.py$"):
"""Search a directory for files and calls check_license()."""
missing_license = False
NEXUS3_PROJ_NAME_HEADER = ""
DOCKER_PROJ_NAME_HEADER = ""
VERSION_REGEXP = ""
-DEFAULT_REGEXP = "^\d+.\d+.\d+$"
+DEFAULT_REGEXP = r"^\d+.\d+.\d+$"
def _remove_http_from_url(url):
self.repofromfile = repo_from_file
def _validate_tag(self, check_tag):
- """Local helper function to simplify validity check of version number.
+ r"""Local helper function to simplify validity check of version number.
Returns true or false, depending if the version pattern is a valid one.
Valid pattern is #.#.#, or in computer term "^\d+.\d+.\d+$"
Strict = True : --> "/org/o-ran-sc/org/"
"""
- repotarget = "^/{}/.*".format(group_id.replace(".", "[/\.]"))
+ repotarget = "^/{}/.*".format(group_id.replace(".", r"[/\.]"))
if strict:
return repotarget
else:
# Replace - with regex
- return repotarget.replace("-", "[/\.]")
+ return repotarget.replace("-", r"[/\.]")
"""Test TagClass"""
org = "onap"
repo = "base/sdc-sanity"
- test_regexp = "^v\d+.\d+.\d+$"
+ test_regexp = r"^v\d+.\d+.\d+$"
repo_from_file = False
test_tags = ["v1.2.3", "v1.22.333", "v111.22.3", "v10.11.12", "v1.0.3"]
rdh.initialize(org, test_regexp)
"""Test TagClass"""
org = "onap"
repo = "base/sdc-sanity"
- test_regexp = "v^\d+.\d+.\d+$"
+ test_regexp = r"v^\d+.\d+.\d+$"
repo_from_file = False
test_tags = [
"1.2.3",
test_regexp_from_file = os.path.join(str(datafiles), "releasedockerhub_good_regexp")
rdh.initialize(org, test_regexp_from_file)
assert rdh.validate_regexp() == True
- assert rdh.VERSION_REGEXP == "^\d+.\d+"
+ assert rdh.VERSION_REGEXP == r"^\d+.\d+"
def test_tag_class_manual_version_regexp_str_from_file_invalid(self, datafiles):
org = "onap"