repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
fedora-python/pyp2rpm | pyp2rpm/metadata_extractors.py | cut_to_length | def cut_to_length(text, length, delim):
"""Shorten given text on first delimiter after given number
of characters.
"""
cut = text.find(delim, length)
if cut > -1:
return text[:cut]
else:
return text | python | def cut_to_length(text, length, delim):
"""Shorten given text on first delimiter after given number
of characters.
"""
cut = text.find(delim, length)
if cut > -1:
return text[:cut]
else:
return text | [
"def",
"cut_to_length",
"(",
"text",
",",
"length",
",",
"delim",
")",
":",
"cut",
"=",
"text",
".",
"find",
"(",
"delim",
",",
"length",
")",
"if",
"cut",
">",
"-",
"1",
":",
"return",
"text",
"[",
":",
"cut",
"]",
"else",
":",
"return",
"text"
... | Shorten given text on first delimiter after given number
of characters. | [
"Shorten",
"given",
"text",
"on",
"first",
"delimiter",
"after",
"given",
"number",
"of",
"characters",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/metadata_extractors.py#L32-L40 |
fedora-python/pyp2rpm | pyp2rpm/metadata_extractors.py | get_interpreter_path | def get_interpreter_path(version=None):
"""Return the executable of a specified or current version."""
if version and version != str(sys.version_info[0]):
return settings.PYTHON_INTERPRETER + version
else:
return sys.executable | python | def get_interpreter_path(version=None):
"""Return the executable of a specified or current version."""
if version and version != str(sys.version_info[0]):
return settings.PYTHON_INTERPRETER + version
else:
return sys.executable | [
"def",
"get_interpreter_path",
"(",
"version",
"=",
"None",
")",
":",
"if",
"version",
"and",
"version",
"!=",
"str",
"(",
"sys",
".",
"version_info",
"[",
"0",
"]",
")",
":",
"return",
"settings",
".",
"PYTHON_INTERPRETER",
"+",
"version",
"else",
":",
... | Return the executable of a specified or current version. | [
"Return",
"the",
"executable",
"of",
"a",
"specified",
"or",
"current",
"version",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/metadata_extractors.py#L43-L48 |
fedora-python/pyp2rpm | pyp2rpm/metadata_extractors.py | license_from_trove | def license_from_trove(trove):
"""Finds out license from list of trove classifiers.
Args:
trove: list of trove classifiers
Returns:
Fedora name of the package license or empty string, if no licensing
information is found in trove classifiers.
"""
license = []
for classifi... | python | def license_from_trove(trove):
"""Finds out license from list of trove classifiers.
Args:
trove: list of trove classifiers
Returns:
Fedora name of the package license or empty string, if no licensing
information is found in trove classifiers.
"""
license = []
for classifi... | [
"def",
"license_from_trove",
"(",
"trove",
")",
":",
"license",
"=",
"[",
"]",
"for",
"classifier",
"in",
"trove",
":",
"if",
"'License'",
"in",
"classifier",
":",
"stripped",
"=",
"classifier",
".",
"strip",
"(",
")",
"# if taken from EGG-INFO, begins with Clas... | Finds out license from list of trove classifiers.
Args:
trove: list of trove classifiers
Returns:
Fedora name of the package license or empty string, if no licensing
information is found in trove classifiers. | [
"Finds",
"out",
"license",
"from",
"list",
"of",
"trove",
"classifiers",
".",
"Args",
":",
"trove",
":",
"list",
"of",
"trove",
"classifiers",
"Returns",
":",
"Fedora",
"name",
"of",
"the",
"package",
"license",
"or",
"empty",
"string",
"if",
"no",
"licens... | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/metadata_extractors.py#L51-L67 |
fedora-python/pyp2rpm | pyp2rpm/metadata_extractors.py | versions_from_trove | def versions_from_trove(trove):
"""Finds out python version from list of trove classifiers.
Args:
trove: list of trove classifiers
Returns:
python version string
"""
versions = set()
for classifier in trove:
if 'Programming Language :: Python ::' in classifier:
... | python | def versions_from_trove(trove):
"""Finds out python version from list of trove classifiers.
Args:
trove: list of trove classifiers
Returns:
python version string
"""
versions = set()
for classifier in trove:
if 'Programming Language :: Python ::' in classifier:
... | [
"def",
"versions_from_trove",
"(",
"trove",
")",
":",
"versions",
"=",
"set",
"(",
")",
"for",
"classifier",
"in",
"trove",
":",
"if",
"'Programming Language :: Python ::'",
"in",
"classifier",
":",
"ver",
"=",
"classifier",
".",
"split",
"(",
"'::'",
")",
"... | Finds out python version from list of trove classifiers.
Args:
trove: list of trove classifiers
Returns:
python version string | [
"Finds",
"out",
"python",
"version",
"from",
"list",
"of",
"trove",
"classifiers",
".",
"Args",
":",
"trove",
":",
"list",
"of",
"trove",
"classifiers",
"Returns",
":",
"python",
"version",
"string"
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/metadata_extractors.py#L70-L85 |
fedora-python/pyp2rpm | pyp2rpm/metadata_extractors.py | pypi_metadata_extension | def pypi_metadata_extension(extraction_fce):
"""Extracts data from PyPI and merges them with data from extraction
method.
"""
def inner(self, client=None):
data = extraction_fce(self)
if client is None:
logger.warning("Client is None, it was probably disabled")
d... | python | def pypi_metadata_extension(extraction_fce):
"""Extracts data from PyPI and merges them with data from extraction
method.
"""
def inner(self, client=None):
data = extraction_fce(self)
if client is None:
logger.warning("Client is None, it was probably disabled")
d... | [
"def",
"pypi_metadata_extension",
"(",
"extraction_fce",
")",
":",
"def",
"inner",
"(",
"self",
",",
"client",
"=",
"None",
")",
":",
"data",
"=",
"extraction_fce",
"(",
"self",
")",
"if",
"client",
"is",
"None",
":",
"logger",
".",
"warning",
"(",
"\"Cl... | Extracts data from PyPI and merges them with data from extraction
method. | [
"Extracts",
"data",
"from",
"PyPI",
"and",
"merges",
"them",
"with",
"data",
"from",
"extraction",
"method",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/metadata_extractors.py#L88-L120 |
fedora-python/pyp2rpm | pyp2rpm/metadata_extractors.py | venv_metadata_extension | def venv_metadata_extension(extraction_fce):
"""Extracts specific metadata from virtualenv object, merges them with data
from given extraction method.
"""
def inner(self):
data = extraction_fce(self)
if virtualenv is None or not self.venv:
logger.debug("Skipping virtualenv m... | python | def venv_metadata_extension(extraction_fce):
"""Extracts specific metadata from virtualenv object, merges them with data
from given extraction method.
"""
def inner(self):
data = extraction_fce(self)
if virtualenv is None or not self.venv:
logger.debug("Skipping virtualenv m... | [
"def",
"venv_metadata_extension",
"(",
"extraction_fce",
")",
":",
"def",
"inner",
"(",
"self",
")",
":",
"data",
"=",
"extraction_fce",
"(",
"self",
")",
"if",
"virtualenv",
"is",
"None",
"or",
"not",
"self",
".",
"venv",
":",
"logger",
".",
"debug",
"(... | Extracts specific metadata from virtualenv object, merges them with data
from given extraction method. | [
"Extracts",
"specific",
"metadata",
"from",
"virtualenv",
"object",
"merges",
"them",
"with",
"data",
"from",
"given",
"extraction",
"method",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/metadata_extractors.py#L123-L146 |
fedora-python/pyp2rpm | pyp2rpm/metadata_extractors.py | process_description | def process_description(description_fce):
"""Removes special character delimiters, titles
and wraps paragraphs.
"""
def inner(description):
clear_description = \
re.sub(r'\s+', ' ', # multiple whitespaces
# general URLs
re.sub(r'\w+:\/{2}[\d\w-]+(\.[\d\w-]+)*... | python | def process_description(description_fce):
"""Removes special character delimiters, titles
and wraps paragraphs.
"""
def inner(description):
clear_description = \
re.sub(r'\s+', ' ', # multiple whitespaces
# general URLs
re.sub(r'\w+:\/{2}[\d\w-]+(\.[\d\w-]+)*... | [
"def",
"process_description",
"(",
"description_fce",
")",
":",
"def",
"inner",
"(",
"description",
")",
":",
"clear_description",
"=",
"re",
".",
"sub",
"(",
"r'\\s+'",
",",
"' '",
",",
"# multiple whitespaces",
"# general URLs",
"re",
".",
"sub",
"(",
"r'\\w... | Removes special character delimiters, titles
and wraps paragraphs. | [
"Removes",
"special",
"character",
"delimiters",
"titles",
"and",
"wraps",
"paragraphs",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/metadata_extractors.py#L149-L167 |
fedora-python/pyp2rpm | pyp2rpm/metadata_extractors.py | LocalMetadataExtractor.versions_from_archive | def versions_from_archive(self):
"""Return Python versions extracted from trove classifiers. """
py_vers = versions_from_trove(self.classifiers)
return [ver for ver in py_vers if ver != self.unsupported_version] | python | def versions_from_archive(self):
"""Return Python versions extracted from trove classifiers. """
py_vers = versions_from_trove(self.classifiers)
return [ver for ver in py_vers if ver != self.unsupported_version] | [
"def",
"versions_from_archive",
"(",
"self",
")",
":",
"py_vers",
"=",
"versions_from_trove",
"(",
"self",
".",
"classifiers",
")",
"return",
"[",
"ver",
"for",
"ver",
"in",
"py_vers",
"if",
"ver",
"!=",
"self",
".",
"unsupported_version",
"]"
] | Return Python versions extracted from trove classifiers. | [
"Return",
"Python",
"versions",
"extracted",
"from",
"trove",
"classifiers",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/metadata_extractors.py#L205-L208 |
fedora-python/pyp2rpm | pyp2rpm/metadata_extractors.py | LocalMetadataExtractor.srcname | def srcname(self):
"""Return srcname for the macro if the pypi name should be changed.
Those cases are:
- name was provided with -r option
- pypi name is like python-<name>
"""
if self.rpm_name or self.name.startswith(('python-', 'Python-')):
return self.name... | python | def srcname(self):
"""Return srcname for the macro if the pypi name should be changed.
Those cases are:
- name was provided with -r option
- pypi name is like python-<name>
"""
if self.rpm_name or self.name.startswith(('python-', 'Python-')):
return self.name... | [
"def",
"srcname",
"(",
"self",
")",
":",
"if",
"self",
".",
"rpm_name",
"or",
"self",
".",
"name",
".",
"startswith",
"(",
"(",
"'python-'",
",",
"'Python-'",
")",
")",
":",
"return",
"self",
".",
"name_convertor",
".",
"base_name",
"(",
"self",
".",
... | Return srcname for the macro if the pypi name should be changed.
Those cases are:
- name was provided with -r option
- pypi name is like python-<name> | [
"Return",
"srcname",
"for",
"the",
"macro",
"if",
"the",
"pypi",
"name",
"should",
"be",
"changed",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/metadata_extractors.py#L235-L243 |
fedora-python/pyp2rpm | pyp2rpm/metadata_extractors.py | LocalMetadataExtractor.extract_data | def extract_data(self):
"""Extracts data from archive.
Returns:
PackageData object containing the extracted data.
"""
data = PackageData(
local_file=self.local_file,
name=self.name,
pkg_name=self.rpm_name or self.name_convertor.rpm_name(
... | python | def extract_data(self):
"""Extracts data from archive.
Returns:
PackageData object containing the extracted data.
"""
data = PackageData(
local_file=self.local_file,
name=self.name,
pkg_name=self.rpm_name or self.name_convertor.rpm_name(
... | [
"def",
"extract_data",
"(",
"self",
")",
":",
"data",
"=",
"PackageData",
"(",
"local_file",
"=",
"self",
".",
"local_file",
",",
"name",
"=",
"self",
".",
"name",
",",
"pkg_name",
"=",
"self",
".",
"rpm_name",
"or",
"self",
".",
"name_convertor",
".",
... | Extracts data from archive.
Returns:
PackageData object containing the extracted data. | [
"Extracts",
"data",
"from",
"archive",
".",
"Returns",
":",
"PackageData",
"object",
"containing",
"the",
"extracted",
"data",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/metadata_extractors.py#L247-L269 |
fedora-python/pyp2rpm | pyp2rpm/metadata_extractors.py | LocalMetadataExtractor.data_from_archive | def data_from_archive(self):
"""Returns all metadata extractable from the archive.
Returns:
dictionary containing metadata extracted from the archive
"""
archive_data = {}
archive_data['runtime_deps'] = self.runtime_deps
archive_data['build_deps'] = [
... | python | def data_from_archive(self):
"""Returns all metadata extractable from the archive.
Returns:
dictionary containing metadata extracted from the archive
"""
archive_data = {}
archive_data['runtime_deps'] = self.runtime_deps
archive_data['build_deps'] = [
... | [
"def",
"data_from_archive",
"(",
"self",
")",
":",
"archive_data",
"=",
"{",
"}",
"archive_data",
"[",
"'runtime_deps'",
"]",
"=",
"self",
".",
"runtime_deps",
"archive_data",
"[",
"'build_deps'",
"]",
"=",
"[",
"[",
"'BuildRequires'",
",",
"'python2-devel'",
... | Returns all metadata extractable from the archive.
Returns:
dictionary containing metadata extracted from the archive | [
"Returns",
"all",
"metadata",
"extractable",
"from",
"the",
"archive",
".",
"Returns",
":",
"dictionary",
"containing",
"metadata",
"extracted",
"from",
"the",
"archive"
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/metadata_extractors.py#L280-L311 |
fedora-python/pyp2rpm | pyp2rpm/metadata_extractors.py | SetupPyMetadataExtractor.runtime_deps | def runtime_deps(self): # install_requires
"""Returns list of runtime dependencies of the package specified in
setup.py.
Dependencies are in RPM SPECFILE format - see dependency_to_rpm()
for details, but names are already transformed according to
current distro.
Return... | python | def runtime_deps(self): # install_requires
"""Returns list of runtime dependencies of the package specified in
setup.py.
Dependencies are in RPM SPECFILE format - see dependency_to_rpm()
for details, but names are already transformed according to
current distro.
Return... | [
"def",
"runtime_deps",
"(",
"self",
")",
":",
"# install_requires",
"install_requires",
"=",
"self",
".",
"metadata",
"[",
"'install_requires'",
"]",
"if",
"self",
".",
"metadata",
"[",
"'entry_points'",
"]",
"and",
"'setuptools'",
"not",
"in",
"install_requires",... | Returns list of runtime dependencies of the package specified in
setup.py.
Dependencies are in RPM SPECFILE format - see dependency_to_rpm()
for details, but names are already transformed according to
current distro.
Returns:
list of runtime dependencies of the pack... | [
"Returns",
"list",
"of",
"runtime",
"dependencies",
"of",
"the",
"package",
"specified",
"in",
"setup",
".",
"py",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/metadata_extractors.py#L370-L387 |
fedora-python/pyp2rpm | pyp2rpm/metadata_extractors.py | SetupPyMetadataExtractor.build_deps | def build_deps(self): # setup_requires [tests_require, install_requires]
"""Same as runtime_deps, but build dependencies. Test and install
requires are included if package contains test suite to prevent
%check phase crashes because of missing dependencies
Returns:
list of b... | python | def build_deps(self): # setup_requires [tests_require, install_requires]
"""Same as runtime_deps, but build dependencies. Test and install
requires are included if package contains test suite to prevent
%check phase crashes because of missing dependencies
Returns:
list of b... | [
"def",
"build_deps",
"(",
"self",
")",
":",
"# setup_requires [tests_require, install_requires]",
"build_requires",
"=",
"self",
".",
"metadata",
"[",
"'setup_requires'",
"]",
"if",
"self",
".",
"has_test_suite",
":",
"build_requires",
"+=",
"self",
".",
"metadata",
... | Same as runtime_deps, but build dependencies. Test and install
requires are included if package contains test suite to prevent
%check phase crashes because of missing dependencies
Returns:
list of build dependencies of the package | [
"Same",
"as",
"runtime_deps",
"but",
"build",
"dependencies",
".",
"Test",
"and",
"install",
"requires",
"are",
"included",
"if",
"package",
"contains",
"test",
"suite",
"to",
"prevent",
"%check",
"phase",
"crashes",
"because",
"of",
"missing",
"dependencies"
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/metadata_extractors.py#L390-L407 |
fedora-python/pyp2rpm | pyp2rpm/metadata_extractors.py | SetupPyMetadataExtractor.doc_files | def doc_files(self):
"""Returns list of doc files that should be used for %doc in specfile.
Returns:
List of doc files from the archive - only basenames, not full
paths.
"""
doc_files = []
for doc_file_re in settings.DOC_FILES_RE:
doc_files.ext... | python | def doc_files(self):
"""Returns list of doc files that should be used for %doc in specfile.
Returns:
List of doc files from the archive - only basenames, not full
paths.
"""
doc_files = []
for doc_file_re in settings.DOC_FILES_RE:
doc_files.ext... | [
"def",
"doc_files",
"(",
"self",
")",
":",
"doc_files",
"=",
"[",
"]",
"for",
"doc_file_re",
"in",
"settings",
".",
"DOC_FILES_RE",
":",
"doc_files",
".",
"extend",
"(",
"self",
".",
"archive",
".",
"get_files_re",
"(",
"doc_file_re",
",",
"ignorecase",
"=... | Returns list of doc files that should be used for %doc in specfile.
Returns:
List of doc files from the archive - only basenames, not full
paths. | [
"Returns",
"list",
"of",
"doc",
"files",
"that",
"should",
"be",
"used",
"for",
"%doc",
"in",
"specfile",
".",
"Returns",
":",
"List",
"of",
"doc",
"files",
"from",
"the",
"archive",
"-",
"only",
"basenames",
"not",
"full",
"paths",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/metadata_extractors.py#L485-L495 |
fedora-python/pyp2rpm | pyp2rpm/metadata_extractors.py | SetupPyMetadataExtractor.sphinx_dir | def sphinx_dir(self):
"""Returns directory with sphinx documentation, if there is such.
Returns:
Full path to sphinx documentation dir inside the archive, or None
if there is no such.
"""
# search for sphinx dir doc/ or docs/ under the first directory in
#... | python | def sphinx_dir(self):
"""Returns directory with sphinx documentation, if there is such.
Returns:
Full path to sphinx documentation dir inside the archive, or None
if there is no such.
"""
# search for sphinx dir doc/ or docs/ under the first directory in
#... | [
"def",
"sphinx_dir",
"(",
"self",
")",
":",
"# search for sphinx dir doc/ or docs/ under the first directory in",
"# archive (e.g. spam-1.0.0/doc)",
"candidate_dirs",
"=",
"self",
".",
"archive",
".",
"get_directories_re",
"(",
"settings",
".",
"SPHINX_DIR_RE",
",",
"full_pat... | Returns directory with sphinx documentation, if there is such.
Returns:
Full path to sphinx documentation dir inside the archive, or None
if there is no such. | [
"Returns",
"directory",
"with",
"sphinx",
"documentation",
"if",
"there",
"is",
"such",
".",
"Returns",
":",
"Full",
"path",
"to",
"sphinx",
"documentation",
"dir",
"inside",
"the",
"archive",
"or",
"None",
"if",
"there",
"is",
"no",
"such",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/metadata_extractors.py#L498-L515 |
fedora-python/pyp2rpm | pyp2rpm/metadata_extractors.py | SetupPyMetadataExtractor.data_from_archive | def data_from_archive(self):
"""Appends setup.py specific metadata to archive_data."""
archive_data = super(SetupPyMetadataExtractor, self).data_from_archive
archive_data['has_packages'] = self.has_packages
archive_data['packages'] = self.packages
archive_data['has_bundled_egg_... | python | def data_from_archive(self):
"""Appends setup.py specific metadata to archive_data."""
archive_data = super(SetupPyMetadataExtractor, self).data_from_archive
archive_data['has_packages'] = self.has_packages
archive_data['packages'] = self.packages
archive_data['has_bundled_egg_... | [
"def",
"data_from_archive",
"(",
"self",
")",
":",
"archive_data",
"=",
"super",
"(",
"SetupPyMetadataExtractor",
",",
"self",
")",
".",
"data_from_archive",
"archive_data",
"[",
"'has_packages'",
"]",
"=",
"self",
".",
"has_packages",
"archive_data",
"[",
"'packa... | Appends setup.py specific metadata to archive_data. | [
"Appends",
"setup",
".",
"py",
"specific",
"metadata",
"to",
"archive_data",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/metadata_extractors.py#L518-L533 |
fedora-python/pyp2rpm | pyp2rpm/metadata_extractors.py | WheelMetadataExtractor.get_requires | def get_requires(self, requires_types):
"""Extracts requires of given types from metadata file, filter windows
specific requires.
"""
if not isinstance(requires_types, list):
requires_types = list(requires_types)
extracted_requires = []
for requires_name in re... | python | def get_requires(self, requires_types):
"""Extracts requires of given types from metadata file, filter windows
specific requires.
"""
if not isinstance(requires_types, list):
requires_types = list(requires_types)
extracted_requires = []
for requires_name in re... | [
"def",
"get_requires",
"(",
"self",
",",
"requires_types",
")",
":",
"if",
"not",
"isinstance",
"(",
"requires_types",
",",
"list",
")",
":",
"requires_types",
"=",
"list",
"(",
"requires_types",
")",
"extracted_requires",
"=",
"[",
"]",
"for",
"requires_name"... | Extracts requires of given types from metadata file, filter windows
specific requires. | [
"Extracts",
"requires",
"of",
"given",
"types",
"from",
"metadata",
"file",
"filter",
"windows",
"specific",
"requires",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/metadata_extractors.py#L545-L557 |
fedora-python/pyp2rpm | pyp2rpm/package_getters.py | get_url | def get_url(client, name, version, wheel=False, hashed_format=False):
"""Retrieves list of package URLs using PyPI's XML-RPC. Chooses URL
of prefered archive and md5_digest.
"""
try:
release_urls = client.release_urls(name, version)
release_data = client.release_data(name, version)
e... | python | def get_url(client, name, version, wheel=False, hashed_format=False):
"""Retrieves list of package URLs using PyPI's XML-RPC. Chooses URL
of prefered archive and md5_digest.
"""
try:
release_urls = client.release_urls(name, version)
release_data = client.release_data(name, version)
e... | [
"def",
"get_url",
"(",
"client",
",",
"name",
",",
"version",
",",
"wheel",
"=",
"False",
",",
"hashed_format",
"=",
"False",
")",
":",
"try",
":",
"release_urls",
"=",
"client",
".",
"release_urls",
"(",
"name",
",",
"version",
")",
"release_data",
"=",... | Retrieves list of package URLs using PyPI's XML-RPC. Chooses URL
of prefered archive and md5_digest. | [
"Retrieves",
"list",
"of",
"package",
"URLs",
"using",
"PyPI",
"s",
"XML",
"-",
"RPC",
".",
"Chooses",
"URL",
"of",
"prefered",
"archive",
"and",
"md5_digest",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/package_getters.py#L25-L78 |
fedora-python/pyp2rpm | pyp2rpm/package_getters.py | PypiDownloader.get | def get(self, wheel=False):
"""Downloads the package from PyPI.
Returns:
Full path of the downloaded file.
Raises:
PermissionError if the save_dir is not writable.
"""
try:
url = get_url(self.client, self.name, self.version,
... | python | def get(self, wheel=False):
"""Downloads the package from PyPI.
Returns:
Full path of the downloaded file.
Raises:
PermissionError if the save_dir is not writable.
"""
try:
url = get_url(self.client, self.name, self.version,
... | [
"def",
"get",
"(",
"self",
",",
"wheel",
"=",
"False",
")",
":",
"try",
":",
"url",
"=",
"get_url",
"(",
"self",
".",
"client",
",",
"self",
".",
"name",
",",
"self",
".",
"version",
",",
"wheel",
",",
"hashed_format",
"=",
"True",
")",
"[",
"0",... | Downloads the package from PyPI.
Returns:
Full path of the downloaded file.
Raises:
PermissionError if the save_dir is not writable. | [
"Downloads",
"the",
"package",
"from",
"PyPI",
".",
"Returns",
":",
"Full",
"path",
"of",
"the",
"downloaded",
"file",
".",
"Raises",
":",
"PermissionError",
"if",
"the",
"save_dir",
"is",
"not",
"writable",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/package_getters.py#L152-L173 |
fedora-python/pyp2rpm | pyp2rpm/package_getters.py | LocalFileGetter.get | def get(self):
"""Copies file from local filesystem to self.save_dir.
Returns:
Full path of the copied file.
Raises:
EnvironmentError if the file can't be found or the save_dir
is not writable.
"""
if self.local_file.endswith('.whl'):
... | python | def get(self):
"""Copies file from local filesystem to self.save_dir.
Returns:
Full path of the copied file.
Raises:
EnvironmentError if the file can't be found or the save_dir
is not writable.
"""
if self.local_file.endswith('.whl'):
... | [
"def",
"get",
"(",
"self",
")",
":",
"if",
"self",
".",
"local_file",
".",
"endswith",
"(",
"'.whl'",
")",
":",
"self",
".",
"temp_dir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"save_dir",
"=",
"self",
".",
"temp_dir",
"else",
":",
"save_dir",
"="... | Copies file from local filesystem to self.save_dir.
Returns:
Full path of the copied file.
Raises:
EnvironmentError if the file can't be found or the save_dir
is not writable. | [
"Copies",
"file",
"from",
"local",
"filesystem",
"to",
"self",
".",
"save_dir",
".",
"Returns",
":",
"Full",
"path",
"of",
"the",
"copied",
"file",
".",
"Raises",
":",
"EnvironmentError",
"if",
"the",
"file",
"can",
"t",
"be",
"found",
"or",
"the",
"save... | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/package_getters.py#L190-L212 |
fedora-python/pyp2rpm | pyp2rpm/package_getters.py | LocalFileGetter._stripped_name_version | def _stripped_name_version(self):
"""Returns filename stripped of the suffix.
Returns:
Filename stripped of the suffix (extension).
"""
# we don't use splitext, because on "a.tar.gz" it returns ("a.tar",
# "gz")
filename = os.path.basename(self.local_file)
... | python | def _stripped_name_version(self):
"""Returns filename stripped of the suffix.
Returns:
Filename stripped of the suffix (extension).
"""
# we don't use splitext, because on "a.tar.gz" it returns ("a.tar",
# "gz")
filename = os.path.basename(self.local_file)
... | [
"def",
"_stripped_name_version",
"(",
"self",
")",
":",
"# we don't use splitext, because on \"a.tar.gz\" it returns (\"a.tar\",",
"# \"gz\")",
"filename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"self",
".",
"local_file",
")",
"for",
"archive_suffix",
"in",
"sett... | Returns filename stripped of the suffix.
Returns:
Filename stripped of the suffix (extension). | [
"Returns",
"filename",
"stripped",
"of",
"the",
"suffix",
".",
"Returns",
":",
"Filename",
"stripped",
"of",
"the",
"suffix",
"(",
"extension",
")",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/package_getters.py#L215-L229 |
fedora-python/pyp2rpm | pyp2rpm/virtualenv.py | DirsContent.fill | def fill(self, path):
'''
Scans content of directories
'''
self.bindir = set(os.listdir(path + 'bin/'))
self.lib_sitepackages = set(os.listdir(glob.glob(
path + 'lib/python?.?/site-packages/')[0])) | python | def fill(self, path):
'''
Scans content of directories
'''
self.bindir = set(os.listdir(path + 'bin/'))
self.lib_sitepackages = set(os.listdir(glob.glob(
path + 'lib/python?.?/site-packages/')[0])) | [
"def",
"fill",
"(",
"self",
",",
"path",
")",
":",
"self",
".",
"bindir",
"=",
"set",
"(",
"os",
".",
"listdir",
"(",
"path",
"+",
"'bin/'",
")",
")",
"self",
".",
"lib_sitepackages",
"=",
"set",
"(",
"os",
".",
"listdir",
"(",
"glob",
".",
"glob... | Scans content of directories | [
"Scans",
"content",
"of",
"directories"
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/virtualenv.py#L39-L45 |
fedora-python/pyp2rpm | pyp2rpm/virtualenv.py | VirtualEnv.install_package_to_venv | def install_package_to_venv(self):
'''
Installs package given as first argument to virtualenv without
dependencies
'''
try:
self.env.install(self.name, force=True, options=["--no-deps"])
except (ve.PackageInstallationException,
ve.VirtualenvRea... | python | def install_package_to_venv(self):
'''
Installs package given as first argument to virtualenv without
dependencies
'''
try:
self.env.install(self.name, force=True, options=["--no-deps"])
except (ve.PackageInstallationException,
ve.VirtualenvRea... | [
"def",
"install_package_to_venv",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"env",
".",
"install",
"(",
"self",
".",
"name",
",",
"force",
"=",
"True",
",",
"options",
"=",
"[",
"\"--no-deps\"",
"]",
")",
"except",
"(",
"ve",
".",
"PackageInstall... | Installs package given as first argument to virtualenv without
dependencies | [
"Installs",
"package",
"given",
"as",
"first",
"argument",
"to",
"virtualenv",
"without",
"dependencies"
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/virtualenv.py#L81-L92 |
fedora-python/pyp2rpm | pyp2rpm/virtualenv.py | VirtualEnv.get_dirs_differance | def get_dirs_differance(self):
'''
Makes final versions of site_packages and scripts using DirsContent
sub method and filters
'''
try:
diff = self.dirs_after_install - self.dirs_before_install
except ValueError:
raise VirtualenvFailException(
... | python | def get_dirs_differance(self):
'''
Makes final versions of site_packages and scripts using DirsContent
sub method and filters
'''
try:
diff = self.dirs_after_install - self.dirs_before_install
except ValueError:
raise VirtualenvFailException(
... | [
"def",
"get_dirs_differance",
"(",
"self",
")",
":",
"try",
":",
"diff",
"=",
"self",
".",
"dirs_after_install",
"-",
"self",
".",
"dirs_before_install",
"except",
"ValueError",
":",
"raise",
"VirtualenvFailException",
"(",
"\"Some of the DirsContent attributes is unini... | Makes final versions of site_packages and scripts using DirsContent
sub method and filters | [
"Makes",
"final",
"versions",
"of",
"site_packages",
"and",
"scripts",
"using",
"DirsContent",
"sub",
"method",
"and",
"filters"
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/virtualenv.py#L94-L115 |
fedora-python/pyp2rpm | pyp2rpm/bin.py | main | def main(package, v, d, s, r, proxy, srpm, p, b, o, t, venv, autonc, sclize,
**scl_kwargs):
"""Convert PyPI package to RPM specfile or SRPM.
\b
\b\bArguments:
PACKAGE Provide PyPI name of the package or path to compressed
source file.
"""
register_fi... | python | def main(package, v, d, s, r, proxy, srpm, p, b, o, t, venv, autonc, sclize,
**scl_kwargs):
"""Convert PyPI package to RPM specfile or SRPM.
\b
\b\bArguments:
PACKAGE Provide PyPI name of the package or path to compressed
source file.
"""
register_fi... | [
"def",
"main",
"(",
"package",
",",
"v",
",",
"d",
",",
"s",
",",
"r",
",",
"proxy",
",",
"srpm",
",",
"p",
",",
"b",
",",
"o",
",",
"t",
",",
"venv",
",",
"autonc",
",",
"sclize",
",",
"*",
"*",
"scl_kwargs",
")",
":",
"register_file_log_handl... | Convert PyPI package to RPM specfile or SRPM.
\b
\b\bArguments:
PACKAGE Provide PyPI name of the package or path to compressed
source file. | [
"Convert",
"PyPI",
"package",
"to",
"RPM",
"specfile",
"or",
"SRPM",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/bin.py#L170-L253 |
fedora-python/pyp2rpm | pyp2rpm/bin.py | convert_to_scl | def convert_to_scl(spec, scl_options):
"""Convert spec into SCL-style spec file using `spec2scl`.
Args:
spec: (str) a spec file
scl_options: (dict) SCL options provided
Returns:
A converted spec file
"""
scl_options['skip_functions'] = scl_options['skip_functions'].split(','... | python | def convert_to_scl(spec, scl_options):
"""Convert spec into SCL-style spec file using `spec2scl`.
Args:
spec: (str) a spec file
scl_options: (dict) SCL options provided
Returns:
A converted spec file
"""
scl_options['skip_functions'] = scl_options['skip_functions'].split(','... | [
"def",
"convert_to_scl",
"(",
"spec",
",",
"scl_options",
")",
":",
"scl_options",
"[",
"'skip_functions'",
"]",
"=",
"scl_options",
"[",
"'skip_functions'",
"]",
".",
"split",
"(",
"','",
")",
"scl_options",
"[",
"'meta_spec'",
"]",
"=",
"None",
"convertor",
... | Convert spec into SCL-style spec file using `spec2scl`.
Args:
spec: (str) a spec file
scl_options: (dict) SCL options provided
Returns:
A converted spec file | [
"Convert",
"spec",
"into",
"SCL",
"-",
"style",
"spec",
"file",
"using",
"spec2scl",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/bin.py#L256-L268 |
fedora-python/pyp2rpm | pyp2rpm/bin.py | Pyp2rpmCommand.format_options | def format_options(self, ctx, formatter):
"""Writes SCL related options into the formatter as a separate
group.
"""
super(Pyp2rpmCommand, self).format_options(ctx, formatter)
scl_opts = []
for param in self.get_params(ctx):
if isinstance(param, SclizeOption):
... | python | def format_options(self, ctx, formatter):
"""Writes SCL related options into the formatter as a separate
group.
"""
super(Pyp2rpmCommand, self).format_options(ctx, formatter)
scl_opts = []
for param in self.get_params(ctx):
if isinstance(param, SclizeOption):
... | [
"def",
"format_options",
"(",
"self",
",",
"ctx",
",",
"formatter",
")",
":",
"super",
"(",
"Pyp2rpmCommand",
",",
"self",
")",
".",
"format_options",
"(",
"ctx",
",",
"formatter",
")",
"scl_opts",
"=",
"[",
"]",
"for",
"param",
"in",
"self",
".",
"get... | Writes SCL related options into the formatter as a separate
group. | [
"Writes",
"SCL",
"related",
"options",
"into",
"the",
"formatter",
"as",
"a",
"separate",
"group",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/bin.py#L32-L44 |
fedora-python/pyp2rpm | pyp2rpm/bin.py | SclizeOption.handle_parse_result | def handle_parse_result(self, ctx, opts, args):
"""Validate SCL related options before parsing."""
if 'sclize' in opts and not SclConvertor:
raise click.UsageError("Please install spec2scl package to "
"perform SCL-style conversion")
if self.name in... | python | def handle_parse_result(self, ctx, opts, args):
"""Validate SCL related options before parsing."""
if 'sclize' in opts and not SclConvertor:
raise click.UsageError("Please install spec2scl package to "
"perform SCL-style conversion")
if self.name in... | [
"def",
"handle_parse_result",
"(",
"self",
",",
"ctx",
",",
"opts",
",",
"args",
")",
":",
"if",
"'sclize'",
"in",
"opts",
"and",
"not",
"SclConvertor",
":",
"raise",
"click",
".",
"UsageError",
"(",
"\"Please install spec2scl package to \"",
"\"perform SCL-style ... | Validate SCL related options before parsing. | [
"Validate",
"SCL",
"related",
"options",
"before",
"parsing",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/bin.py#L53-L63 |
fedora-python/pyp2rpm | pyp2rpm/command/extract_dist.py | to_list | def to_list(var):
"""Checks if given value is a list, tries to convert, if it is not."""
if var is None:
return []
if isinstance(var, str):
var = var.split('\n')
elif not isinstance(var, list):
try:
var = list(var)
except TypeError:
raise ValueErro... | python | def to_list(var):
"""Checks if given value is a list, tries to convert, if it is not."""
if var is None:
return []
if isinstance(var, str):
var = var.split('\n')
elif not isinstance(var, list):
try:
var = list(var)
except TypeError:
raise ValueErro... | [
"def",
"to_list",
"(",
"var",
")",
":",
"if",
"var",
"is",
"None",
":",
"return",
"[",
"]",
"if",
"isinstance",
"(",
"var",
",",
"str",
")",
":",
"var",
"=",
"var",
".",
"split",
"(",
"'\\n'",
")",
"elif",
"not",
"isinstance",
"(",
"var",
",",
... | Checks if given value is a list, tries to convert, if it is not. | [
"Checks",
"if",
"given",
"value",
"is",
"a",
"list",
"tries",
"to",
"convert",
"if",
"it",
"is",
"not",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/command/extract_dist.py#L75-L86 |
fedora-python/pyp2rpm | pyp2rpm/command/extract_dist.py | extract_dist.run | def run(self):
"""Sends extracted metadata in json format to stdout if stdout
option is specified, assigns metadata dictionary to class_metadata
variable otherwise.
"""
if self.stdout:
sys.stdout.write("extracted json data:\n" + json.dumps(
self.metada... | python | def run(self):
"""Sends extracted metadata in json format to stdout if stdout
option is specified, assigns metadata dictionary to class_metadata
variable otherwise.
"""
if self.stdout:
sys.stdout.write("extracted json data:\n" + json.dumps(
self.metada... | [
"def",
"run",
"(",
"self",
")",
":",
"if",
"self",
".",
"stdout",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"\"extracted json data:\\n\"",
"+",
"json",
".",
"dumps",
"(",
"self",
".",
"metadata",
",",
"default",
"=",
"to_str",
")",
"+",
"\"\\n\"",
... | Sends extracted metadata in json format to stdout if stdout
option is specified, assigns metadata dictionary to class_metadata
variable otherwise. | [
"Sends",
"extracted",
"metadata",
"in",
"json",
"format",
"to",
"stdout",
"if",
"stdout",
"option",
"is",
"specified",
"assigns",
"metadata",
"dictionary",
"to",
"class_metadata",
"variable",
"otherwise",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/command/extract_dist.py#L63-L72 |
fedora-python/pyp2rpm | pyp2rpm/dependency_parser.py | dependency_to_rpm | def dependency_to_rpm(dep, runtime):
"""Converts a dependency got by pkg_resources.Requirement.parse()
to RPM format.
Args:
dep - a dependency retrieved by pkg_resources.Requirement.parse()
runtime - whether the returned dependency should be runtime (True)
or build time (False)
R... | python | def dependency_to_rpm(dep, runtime):
"""Converts a dependency got by pkg_resources.Requirement.parse()
to RPM format.
Args:
dep - a dependency retrieved by pkg_resources.Requirement.parse()
runtime - whether the returned dependency should be runtime (True)
or build time (False)
R... | [
"def",
"dependency_to_rpm",
"(",
"dep",
",",
"runtime",
")",
":",
"logger",
".",
"debug",
"(",
"'Dependencies provided: {0} runtime: {1}.'",
".",
"format",
"(",
"dep",
",",
"runtime",
")",
")",
"converted",
"=",
"[",
"]",
"if",
"not",
"len",
"(",
"dep",
".... | Converts a dependency got by pkg_resources.Requirement.parse()
to RPM format.
Args:
dep - a dependency retrieved by pkg_resources.Requirement.parse()
runtime - whether the returned dependency should be runtime (True)
or build time (False)
Returns:
List of semi-SPECFILE depend... | [
"Converts",
"a",
"dependency",
"got",
"by",
"pkg_resources",
".",
"Requirement",
".",
"parse",
"()",
"to",
"RPM",
"format",
".",
"Args",
":",
"dep",
"-",
"a",
"dependency",
"retrieved",
"by",
"pkg_resources",
".",
"Requirement",
".",
"parse",
"()",
"runtime"... | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/dependency_parser.py#L9-L44 |
fedora-python/pyp2rpm | pyp2rpm/dependency_parser.py | deps_from_pyp_format | def deps_from_pyp_format(requires, runtime=True):
"""Parses dependencies extracted from setup.py.
Args:
requires: list of dependencies as written in setup.py of the package.
runtime: are the dependencies runtime (True) or build time (False)?
Returns:
List of semi-SPECFILE dependencie... | python | def deps_from_pyp_format(requires, runtime=True):
"""Parses dependencies extracted from setup.py.
Args:
requires: list of dependencies as written in setup.py of the package.
runtime: are the dependencies runtime (True) or build time (False)?
Returns:
List of semi-SPECFILE dependencie... | [
"def",
"deps_from_pyp_format",
"(",
"requires",
",",
"runtime",
"=",
"True",
")",
":",
"parsed",
"=",
"[",
"]",
"logger",
".",
"debug",
"(",
"\"Dependencies from setup.py: {0} runtime: {1}.\"",
".",
"format",
"(",
"requires",
",",
"runtime",
")",
")",
"for",
"... | Parses dependencies extracted from setup.py.
Args:
requires: list of dependencies as written in setup.py of the package.
runtime: are the dependencies runtime (True) or build time (False)?
Returns:
List of semi-SPECFILE dependencies (see dependency_to_rpm for format). | [
"Parses",
"dependencies",
"extracted",
"from",
"setup",
".",
"py",
".",
"Args",
":",
"requires",
":",
"list",
"of",
"dependencies",
"as",
"written",
"in",
"setup",
".",
"py",
"of",
"the",
"package",
".",
"runtime",
":",
"are",
"the",
"dependencies",
"runti... | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/dependency_parser.py#L47-L72 |
fedora-python/pyp2rpm | pyp2rpm/dependency_parser.py | deps_from_pydit_json | def deps_from_pydit_json(requires, runtime=True):
"""Parses dependencies returned by pydist.json, since versions
uses brackets we can't use pkg_resources to parse and we need a separate
method
Args:
requires: list of dependencies as written in pydist.json of the package
runtime: are the ... | python | def deps_from_pydit_json(requires, runtime=True):
"""Parses dependencies returned by pydist.json, since versions
uses brackets we can't use pkg_resources to parse and we need a separate
method
Args:
requires: list of dependencies as written in pydist.json of the package
runtime: are the ... | [
"def",
"deps_from_pydit_json",
"(",
"requires",
",",
"runtime",
"=",
"True",
")",
":",
"parsed",
"=",
"[",
"]",
"for",
"req",
"in",
"requires",
":",
"# req looks like 'some-name (>=X.Y,!=Y.X)' or 'someme-name' where",
"# 'some-name' is the name of required package and '(>=X.Y... | Parses dependencies returned by pydist.json, since versions
uses brackets we can't use pkg_resources to parse and we need a separate
method
Args:
requires: list of dependencies as written in pydist.json of the package
runtime: are the dependencies runtime (True) or build time (False)
Ret... | [
"Parses",
"dependencies",
"returned",
"by",
"pydist",
".",
"json",
"since",
"versions",
"uses",
"brackets",
"we",
"can",
"t",
"use",
"pkg_resources",
"to",
"parse",
"and",
"we",
"need",
"a",
"separate",
"method",
"Args",
":",
"requires",
":",
"list",
"of",
... | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/dependency_parser.py#L75-L123 |
fedora-python/pyp2rpm | pyp2rpm/package_data.py | PackageData.get_changelog_date_packager | def get_changelog_date_packager(self):
"""Returns part of the changelog entry, containing date and packager.
"""
try:
packager = subprocess.Popen(
'rpmdev-packager', stdout=subprocess.PIPE).communicate(
)[0].strip()
except OSError:
... | python | def get_changelog_date_packager(self):
"""Returns part of the changelog entry, containing date and packager.
"""
try:
packager = subprocess.Popen(
'rpmdev-packager', stdout=subprocess.PIPE).communicate(
)[0].strip()
except OSError:
... | [
"def",
"get_changelog_date_packager",
"(",
"self",
")",
":",
"try",
":",
"packager",
"=",
"subprocess",
".",
"Popen",
"(",
"'rpmdev-packager'",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
")",
".",
"communicate",
"(",
")",
"[",
"0",
"]",
".",
"strip",
... | Returns part of the changelog entry, containing date and packager. | [
"Returns",
"part",
"of",
"the",
"changelog",
"entry",
"containing",
"date",
"and",
"packager",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/package_data.py#L89-L104 |
fedora-python/pyp2rpm | pyp2rpm/module_runners.py | RunpyModuleRunner.run | def run(self):
"""Executes the code of the specified module."""
with utils.ChangeDir(self.dirname):
sys.path.insert(0, self.dirname)
sys.argv[1:] = self.args
runpy.run_module(self.not_suffixed(self.filename),
run_name='__main__',
... | python | def run(self):
"""Executes the code of the specified module."""
with utils.ChangeDir(self.dirname):
sys.path.insert(0, self.dirname)
sys.argv[1:] = self.args
runpy.run_module(self.not_suffixed(self.filename),
run_name='__main__',
... | [
"def",
"run",
"(",
"self",
")",
":",
"with",
"utils",
".",
"ChangeDir",
"(",
"self",
".",
"dirname",
")",
":",
"sys",
".",
"path",
".",
"insert",
"(",
"0",
",",
"self",
".",
"dirname",
")",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"=",
"self",
... | Executes the code of the specified module. | [
"Executes",
"the",
"code",
"of",
"the",
"specified",
"module",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/module_runners.py#L35-L42 |
fedora-python/pyp2rpm | pyp2rpm/module_runners.py | SubprocessModuleRunner.run | def run(self, interpreter):
"""Executes the code of the specified module. Deserializes captured
json data.
"""
with utils.ChangeDir(self.dirname):
command_list = ['PYTHONPATH=' + main_dir, interpreter,
self.filename] + list(self.args)
t... | python | def run(self, interpreter):
"""Executes the code of the specified module. Deserializes captured
json data.
"""
with utils.ChangeDir(self.dirname):
command_list = ['PYTHONPATH=' + main_dir, interpreter,
self.filename] + list(self.args)
t... | [
"def",
"run",
"(",
"self",
",",
"interpreter",
")",
":",
"with",
"utils",
".",
"ChangeDir",
"(",
"self",
".",
"dirname",
")",
":",
"command_list",
"=",
"[",
"'PYTHONPATH='",
"+",
"main_dir",
",",
"interpreter",
",",
"self",
".",
"filename",
"]",
"+",
"... | Executes the code of the specified module. Deserializes captured
json data. | [
"Executes",
"the",
"code",
"of",
"the",
"specified",
"module",
".",
"Deserializes",
"captured",
"json",
"data",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/module_runners.py#L52-L73 |
fedora-python/pyp2rpm | pyp2rpm/archive.py | generator_to_list | def generator_to_list(fn):
"""This decorator is for flat_list function.
It converts returned generator to list.
"""
def wrapper(*args, **kw):
return list(fn(*args, **kw))
return wrapper | python | def generator_to_list(fn):
"""This decorator is for flat_list function.
It converts returned generator to list.
"""
def wrapper(*args, **kw):
return list(fn(*args, **kw))
return wrapper | [
"def",
"generator_to_list",
"(",
"fn",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"return",
"list",
"(",
"fn",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
")",
"return",
"wrapper"
] | This decorator is for flat_list function.
It converts returned generator to list. | [
"This",
"decorator",
"is",
"for",
"flat_list",
"function",
".",
"It",
"converts",
"returned",
"generator",
"to",
"list",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/archive.py#L17-L23 |
fedora-python/pyp2rpm | pyp2rpm/archive.py | flat_list | def flat_list(lst):
"""This function flatten given nested list.
Argument:
nested list
Returns:
flat list
"""
if isinstance(lst, list):
for item in lst:
for i in flat_list(item):
yield i
else:
yield lst | python | def flat_list(lst):
"""This function flatten given nested list.
Argument:
nested list
Returns:
flat list
"""
if isinstance(lst, list):
for item in lst:
for i in flat_list(item):
yield i
else:
yield lst | [
"def",
"flat_list",
"(",
"lst",
")",
":",
"if",
"isinstance",
"(",
"lst",
",",
"list",
")",
":",
"for",
"item",
"in",
"lst",
":",
"for",
"i",
"in",
"flat_list",
"(",
"item",
")",
":",
"yield",
"i",
"else",
":",
"yield",
"lst"
] | This function flatten given nested list.
Argument:
nested list
Returns:
flat list | [
"This",
"function",
"flatten",
"given",
"nested",
"list",
".",
"Argument",
":",
"nested",
"list",
"Returns",
":",
"flat",
"list"
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/archive.py#L27-L39 |
fedora-python/pyp2rpm | pyp2rpm/archive.py | Archive.extractor_cls | def extractor_cls(self):
"""Returns the class that can read this archive based on archive suffix.
Returns:
Class that can read this archive or None if no such exists.
"""
file_cls = None
# only catches ".gz", even from ".tar.gz"
if self.is_tar:
fi... | python | def extractor_cls(self):
"""Returns the class that can read this archive based on archive suffix.
Returns:
Class that can read this archive or None if no such exists.
"""
file_cls = None
# only catches ".gz", even from ".tar.gz"
if self.is_tar:
fi... | [
"def",
"extractor_cls",
"(",
"self",
")",
":",
"file_cls",
"=",
"None",
"# only catches \".gz\", even from \".tar.gz\"",
"if",
"self",
".",
"is_tar",
":",
"file_cls",
"=",
"TarFile",
"elif",
"self",
".",
"is_zip",
":",
"file_cls",
"=",
"ZipFile",
"else",
":",
... | Returns the class that can read this archive based on archive suffix.
Returns:
Class that can read this archive or None if no such exists. | [
"Returns",
"the",
"class",
"that",
"can",
"read",
"this",
"archive",
"based",
"on",
"archive",
"suffix",
".",
"Returns",
":",
"Class",
"that",
"can",
"read",
"this",
"archive",
"or",
"None",
"if",
"no",
"such",
"exists",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/archive.py#L127-L143 |
fedora-python/pyp2rpm | pyp2rpm/archive.py | Archive.get_content_of_file | def get_content_of_file(self, name, full_path=False):
"""Returns content of file from archive.
If full_path is set to False and two files with given name exist,
content of one is returned (it is not specified which one that is).
If set to True, returns content of exactly that file.
... | python | def get_content_of_file(self, name, full_path=False):
"""Returns content of file from archive.
If full_path is set to False and two files with given name exist,
content of one is returned (it is not specified which one that is).
If set to True, returns content of exactly that file.
... | [
"def",
"get_content_of_file",
"(",
"self",
",",
"name",
",",
"full_path",
"=",
"False",
")",
":",
"if",
"self",
".",
"handle",
":",
"for",
"member",
"in",
"self",
".",
"handle",
".",
"getmembers",
"(",
")",
":",
"if",
"(",
"full_path",
"and",
"member",... | Returns content of file from archive.
If full_path is set to False and two files with given name exist,
content of one is returned (it is not specified which one that is).
If set to True, returns content of exactly that file.
Args:
name: name of the file to get content of
... | [
"Returns",
"content",
"of",
"file",
"from",
"archive",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/archive.py#L147-L168 |
fedora-python/pyp2rpm | pyp2rpm/archive.py | Archive.extract_file | def extract_file(self, name, full_path=False, directory="."):
"""Extract a member from the archive to the specified working directory.
Behaviour of name and pull_path is the same as in function
get_content_of_file.
"""
if self.handle:
for member in self.handle.getmemb... | python | def extract_file(self, name, full_path=False, directory="."):
"""Extract a member from the archive to the specified working directory.
Behaviour of name and pull_path is the same as in function
get_content_of_file.
"""
if self.handle:
for member in self.handle.getmemb... | [
"def",
"extract_file",
"(",
"self",
",",
"name",
",",
"full_path",
"=",
"False",
",",
"directory",
"=",
"\".\"",
")",
":",
"if",
"self",
".",
"handle",
":",
"for",
"member",
"in",
"self",
".",
"handle",
".",
"getmembers",
"(",
")",
":",
"if",
"(",
... | Extract a member from the archive to the specified working directory.
Behaviour of name and pull_path is the same as in function
get_content_of_file. | [
"Extract",
"a",
"member",
"from",
"the",
"archive",
"to",
"the",
"specified",
"working",
"directory",
".",
"Behaviour",
"of",
"name",
"and",
"pull_path",
"is",
"the",
"same",
"as",
"in",
"function",
"get_content_of_file",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/archive.py#L170-L181 |
fedora-python/pyp2rpm | pyp2rpm/archive.py | Archive.extract_all | def extract_all(self, directory=".", members=None):
"""Extract all member from the archive to the specified working
directory.
"""
if self.handle:
self.handle.extractall(path=directory, members=members) | python | def extract_all(self, directory=".", members=None):
"""Extract all member from the archive to the specified working
directory.
"""
if self.handle:
self.handle.extractall(path=directory, members=members) | [
"def",
"extract_all",
"(",
"self",
",",
"directory",
"=",
"\".\"",
",",
"members",
"=",
"None",
")",
":",
"if",
"self",
".",
"handle",
":",
"self",
".",
"handle",
".",
"extractall",
"(",
"path",
"=",
"directory",
",",
"members",
"=",
"members",
")"
] | Extract all member from the archive to the specified working
directory. | [
"Extract",
"all",
"member",
"from",
"the",
"archive",
"to",
"the",
"specified",
"working",
"directory",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/archive.py#L183-L188 |
fedora-python/pyp2rpm | pyp2rpm/archive.py | Archive.has_file_with_suffix | def has_file_with_suffix(self, suffixes):
"""Finds out if there is a file with one of suffixes in the archive.
Args:
suffixes: list of suffixes or single suffix to look for
Returns:
True if there is at least one file with at least one given suffix
in the archi... | python | def has_file_with_suffix(self, suffixes):
"""Finds out if there is a file with one of suffixes in the archive.
Args:
suffixes: list of suffixes or single suffix to look for
Returns:
True if there is at least one file with at least one given suffix
in the archi... | [
"def",
"has_file_with_suffix",
"(",
"self",
",",
"suffixes",
")",
":",
"if",
"not",
"isinstance",
"(",
"suffixes",
",",
"list",
")",
":",
"suffixes",
"=",
"[",
"suffixes",
"]",
"if",
"self",
".",
"handle",
":",
"for",
"member",
"in",
"self",
".",
"hand... | Finds out if there is a file with one of suffixes in the archive.
Args:
suffixes: list of suffixes or single suffix to look for
Returns:
True if there is at least one file with at least one given suffix
in the archive, False otherwise (or archive can't be opened) | [
"Finds",
"out",
"if",
"there",
"is",
"a",
"file",
"with",
"one",
"of",
"suffixes",
"in",
"the",
"archive",
".",
"Args",
":",
"suffixes",
":",
"list",
"of",
"suffixes",
"or",
"single",
"suffix",
"to",
"look",
"for",
"Returns",
":",
"True",
"if",
"there"... | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/archive.py#L191-L213 |
fedora-python/pyp2rpm | pyp2rpm/archive.py | Archive.get_files_re | def get_files_re(self, file_re, full_path=False, ignorecase=False):
"""Finds all files that match file_re and returns their list.
Doesn't return directories, only files.
Args:
file_re: raw string to match files against (gets compiled into re)
full_path: whether to match ... | python | def get_files_re(self, file_re, full_path=False, ignorecase=False):
"""Finds all files that match file_re and returns their list.
Doesn't return directories, only files.
Args:
file_re: raw string to match files against (gets compiled into re)
full_path: whether to match ... | [
"def",
"get_files_re",
"(",
"self",
",",
"file_re",
",",
"full_path",
"=",
"False",
",",
"ignorecase",
"=",
"False",
")",
":",
"try",
":",
"if",
"ignorecase",
":",
"compiled_re",
"=",
"re",
".",
"compile",
"(",
"file_re",
",",
"re",
".",
"I",
")",
"e... | Finds all files that match file_re and returns their list.
Doesn't return directories, only files.
Args:
file_re: raw string to match files against (gets compiled into re)
full_path: whether to match against full path inside the archive
or just the filenames
... | [
"Finds",
"all",
"files",
"that",
"match",
"file_re",
"and",
"returns",
"their",
"list",
".",
"Doesn",
"t",
"return",
"directories",
"only",
"files",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/archive.py#L215-L248 |
fedora-python/pyp2rpm | pyp2rpm/archive.py | Archive.get_directories_re | def get_directories_re(
self,
directory_re,
full_path=False,
ignorecase=False):
"""Same as get_files_re, but for directories"""
if ignorecase:
compiled_re = re.compile(directory_re, re.I)
else:
compiled_re = re.compile(direc... | python | def get_directories_re(
self,
directory_re,
full_path=False,
ignorecase=False):
"""Same as get_files_re, but for directories"""
if ignorecase:
compiled_re = re.compile(directory_re, re.I)
else:
compiled_re = re.compile(direc... | [
"def",
"get_directories_re",
"(",
"self",
",",
"directory_re",
",",
"full_path",
"=",
"False",
",",
"ignorecase",
"=",
"False",
")",
":",
"if",
"ignorecase",
":",
"compiled_re",
"=",
"re",
".",
"compile",
"(",
"directory_re",
",",
"re",
".",
"I",
")",
"e... | Same as get_files_re, but for directories | [
"Same",
"as",
"get_files_re",
"but",
"for",
"directories"
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/archive.py#L250-L279 |
fedora-python/pyp2rpm | pyp2rpm/archive.py | Archive.top_directory | def top_directory(self):
"""Return the name of the archive topmost directory."""
if self.handle:
return os.path.commonprefix(self.handle.getnames()).rstrip('/') | python | def top_directory(self):
"""Return the name of the archive topmost directory."""
if self.handle:
return os.path.commonprefix(self.handle.getnames()).rstrip('/') | [
"def",
"top_directory",
"(",
"self",
")",
":",
"if",
"self",
".",
"handle",
":",
"return",
"os",
".",
"path",
".",
"commonprefix",
"(",
"self",
".",
"handle",
".",
"getnames",
"(",
")",
")",
".",
"rstrip",
"(",
"'/'",
")"
] | Return the name of the archive topmost directory. | [
"Return",
"the",
"name",
"of",
"the",
"archive",
"topmost",
"directory",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/archive.py#L282-L285 |
fedora-python/pyp2rpm | pyp2rpm/archive.py | Archive.json_wheel_metadata | def json_wheel_metadata(self):
"""Simple getter that get content of metadata.json file in .whl archive
Returns:
metadata from metadata.json or pydist.json in json format
"""
for meta_file in ("metadata.json", "pydist.json"):
try:
return json.loads(... | python | def json_wheel_metadata(self):
"""Simple getter that get content of metadata.json file in .whl archive
Returns:
metadata from metadata.json or pydist.json in json format
"""
for meta_file in ("metadata.json", "pydist.json"):
try:
return json.loads(... | [
"def",
"json_wheel_metadata",
"(",
"self",
")",
":",
"for",
"meta_file",
"in",
"(",
"\"metadata.json\"",
",",
"\"pydist.json\"",
")",
":",
"try",
":",
"return",
"json",
".",
"loads",
"(",
"self",
".",
"get_content_of_file",
"(",
"meta_file",
")",
")",
"excep... | Simple getter that get content of metadata.json file in .whl archive
Returns:
metadata from metadata.json or pydist.json in json format | [
"Simple",
"getter",
"that",
"get",
"content",
"of",
"metadata",
".",
"json",
"file",
"in",
".",
"whl",
"archive",
"Returns",
":",
"metadata",
"from",
"metadata",
".",
"json",
"or",
"pydist",
".",
"json",
"in",
"json",
"format"
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/archive.py#L288-L305 |
fedora-python/pyp2rpm | pyp2rpm/archive.py | Archive.record | def record(self):
"""Getter that get content of RECORD file in .whl archive
Returns:
dict with keys `modules` and `scripts`
"""
modules = []
scripts = []
if self.get_content_of_file('RECORD'):
lines = self.get_content_of_file('RECORD').splitlines(... | python | def record(self):
"""Getter that get content of RECORD file in .whl archive
Returns:
dict with keys `modules` and `scripts`
"""
modules = []
scripts = []
if self.get_content_of_file('RECORD'):
lines = self.get_content_of_file('RECORD').splitlines(... | [
"def",
"record",
"(",
"self",
")",
":",
"modules",
"=",
"[",
"]",
"scripts",
"=",
"[",
"]",
"if",
"self",
".",
"get_content_of_file",
"(",
"'RECORD'",
")",
":",
"lines",
"=",
"self",
".",
"get_content_of_file",
"(",
"'RECORD'",
")",
".",
"splitlines",
... | Getter that get content of RECORD file in .whl archive
Returns:
dict with keys `modules` and `scripts` | [
"Getter",
"that",
"get",
"content",
"of",
"RECORD",
"file",
"in",
".",
"whl",
"archive",
"Returns",
":",
"dict",
"with",
"keys",
"modules",
"and",
"scripts"
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/archive.py#L312-L334 |
fedora-python/pyp2rpm | pyp2rpm/name_convertor.py | NameConvertor.rpm_versioned_name | def rpm_versioned_name(cls, name, version, default_number=False):
"""Properly versions the name.
For example:
rpm_versioned_name('python-foo', '26') will return python26-foo
rpm_versioned_name('pyfoo, '3') will return python3-pyfoo
If version is same as settings.DEFAULT_PYTHON_V... | python | def rpm_versioned_name(cls, name, version, default_number=False):
"""Properly versions the name.
For example:
rpm_versioned_name('python-foo', '26') will return python26-foo
rpm_versioned_name('pyfoo, '3') will return python3-pyfoo
If version is same as settings.DEFAULT_PYTHON_V... | [
"def",
"rpm_versioned_name",
"(",
"cls",
",",
"name",
",",
"version",
",",
"default_number",
"=",
"False",
")",
":",
"regexp",
"=",
"re",
".",
"compile",
"(",
"r'^python(\\d*|)-(.*)'",
")",
"auto_provides_regexp",
"=",
"re",
".",
"compile",
"(",
"r'^python(\\d... | Properly versions the name.
For example:
rpm_versioned_name('python-foo', '26') will return python26-foo
rpm_versioned_name('pyfoo, '3') will return python3-pyfoo
If version is same as settings.DEFAULT_PYTHON_VERSION, no change
is done.
Args:
name: name to v... | [
"Properly",
"versions",
"the",
"name",
".",
"For",
"example",
":",
"rpm_versioned_name",
"(",
"python",
"-",
"foo",
"26",
")",
"will",
"return",
"python26",
"-",
"foo",
"rpm_versioned_name",
"(",
"pyfoo",
"3",
")",
"will",
"return",
"python3",
"-",
"pyfoo"
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/name_convertor.py#L36-L81 |
fedora-python/pyp2rpm | pyp2rpm/name_convertor.py | NameConvertor.rpm_name | def rpm_name(self, name, python_version=None, pkg_name=False):
"""Returns name of the package converted to (possibly) correct package
name according to Packaging Guidelines.
Args:
name: name to convert
python_version: python version for which to retrieve the name of
... | python | def rpm_name(self, name, python_version=None, pkg_name=False):
"""Returns name of the package converted to (possibly) correct package
name according to Packaging Guidelines.
Args:
name: name to convert
python_version: python version for which to retrieve the name of
... | [
"def",
"rpm_name",
"(",
"self",
",",
"name",
",",
"python_version",
"=",
"None",
",",
"pkg_name",
"=",
"False",
")",
":",
"logger",
".",
"debug",
"(",
"\"Converting name: {0} to rpm name, version: {1}.\"",
".",
"format",
"(",
"name",
",",
"python_version",
")",
... | Returns name of the package converted to (possibly) correct package
name according to Packaging Guidelines.
Args:
name: name to convert
python_version: python version for which to retrieve the name of
the package
pkg_name: flag to perfor... | [
"Returns",
"name",
"of",
"the",
"package",
"converted",
"to",
"(",
"possibly",
")",
"correct",
"package",
"name",
"according",
"to",
"Packaging",
"Guidelines",
".",
"Args",
":",
"name",
":",
"name",
"to",
"convert",
"python_version",
":",
"python",
"version",
... | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/name_convertor.py#L83-L106 |
fedora-python/pyp2rpm | pyp2rpm/name_convertor.py | NameConvertor.base_name | def base_name(self, name):
"""Removes any python prefixes of suffixes from name if present."""
base_name = name.replace('.', "-")
# remove python prefix if present
found_prefix = self.reg_start.search(name)
if found_prefix:
base_name = found_prefix.group(2)
#... | python | def base_name(self, name):
"""Removes any python prefixes of suffixes from name if present."""
base_name = name.replace('.', "-")
# remove python prefix if present
found_prefix = self.reg_start.search(name)
if found_prefix:
base_name = found_prefix.group(2)
#... | [
"def",
"base_name",
"(",
"self",
",",
"name",
")",
":",
"base_name",
"=",
"name",
".",
"replace",
"(",
"'.'",
",",
"\"-\"",
")",
"# remove python prefix if present",
"found_prefix",
"=",
"self",
".",
"reg_start",
".",
"search",
"(",
"name",
")",
"if",
"fou... | Removes any python prefixes of suffixes from name if present. | [
"Removes",
"any",
"python",
"prefixes",
"of",
"suffixes",
"from",
"name",
"if",
"present",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/name_convertor.py#L108-L121 |
fedora-python/pyp2rpm | pyp2rpm/name_convertor.py | NameVariants.merge | def merge(self, other):
"""Merges object with other NameVariants object, not set values
of self.variants are replace by values from other object.
"""
if not isinstance(other, NameVariants):
raise TypeError("NameVariants isinstance can be merge with"
... | python | def merge(self, other):
"""Merges object with other NameVariants object, not set values
of self.variants are replace by values from other object.
"""
if not isinstance(other, NameVariants):
raise TypeError("NameVariants isinstance can be merge with"
... | [
"def",
"merge",
"(",
"self",
",",
"other",
")",
":",
"if",
"not",
"isinstance",
"(",
"other",
",",
"NameVariants",
")",
":",
"raise",
"TypeError",
"(",
"\"NameVariants isinstance can be merge with\"",
"\"other isinstance of the same class\"",
")",
"for",
"key",
"in"... | Merges object with other NameVariants object, not set values
of self.variants are replace by values from other object. | [
"Merges",
"object",
"with",
"other",
"NameVariants",
"object",
"not",
"set",
"values",
"of",
"self",
".",
"variants",
"are",
"replace",
"by",
"values",
"from",
"other",
"object",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/name_convertor.py#L144-L154 |
fedora-python/pyp2rpm | pyp2rpm/name_convertor.py | DandifiedNameConvertor.rpm_name | def rpm_name(self, name, python_version=None, pkg_name=False):
"""Checks if name converted using superclass rpm_name_method match name
of package in the query. Searches for correct name if it doesn't.
Args:
name: name to convert
python_version: python version for which to... | python | def rpm_name(self, name, python_version=None, pkg_name=False):
"""Checks if name converted using superclass rpm_name_method match name
of package in the query. Searches for correct name if it doesn't.
Args:
name: name to convert
python_version: python version for which to... | [
"def",
"rpm_name",
"(",
"self",
",",
"name",
",",
"python_version",
"=",
"None",
",",
"pkg_name",
"=",
"False",
")",
":",
"if",
"pkg_name",
":",
"return",
"super",
"(",
"DandifiedNameConvertor",
",",
"self",
")",
".",
"rpm_name",
"(",
"name",
",",
"pytho... | Checks if name converted using superclass rpm_name_method match name
of package in the query. Searches for correct name if it doesn't.
Args:
name: name to convert
python_version: python version for which to retrieve the name of
the package
... | [
"Checks",
"if",
"name",
"converted",
"using",
"superclass",
"rpm_name_method",
"match",
"name",
"of",
"package",
"in",
"the",
"query",
".",
"Searches",
"for",
"correct",
"name",
"if",
"it",
"doesn",
"t",
".",
"Args",
":",
"name",
":",
"name",
"to",
"conver... | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/name_convertor.py#L195-L239 |
fedora-python/pyp2rpm | pyp2rpm/convertor.py | Convertor.merge_versions | def merge_versions(self, data):
"""Merges python versions specified in command lines options with
extracted versions, checks if some of the versions is not > 2 if EPEL6
template will be used. attributes base_python_version and
python_versions contain values specified by command line opti... | python | def merge_versions(self, data):
"""Merges python versions specified in command lines options with
extracted versions, checks if some of the versions is not > 2 if EPEL6
template will be used. attributes base_python_version and
python_versions contain values specified by command line opti... | [
"def",
"merge_versions",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"template",
"==",
"\"epel6.spec\"",
":",
"# if user requested version greater than 2, writes error message",
"# and exits",
"requested_versions",
"=",
"self",
".",
"python_versions",
"if",
"... | Merges python versions specified in command lines options with
extracted versions, checks if some of the versions is not > 2 if EPEL6
template will be used. attributes base_python_version and
python_versions contain values specified by command line options or
default values, data.python_... | [
"Merges",
"python",
"versions",
"specified",
"in",
"command",
"lines",
"options",
"with",
"extracted",
"versions",
"checks",
"if",
"some",
"of",
"the",
"versions",
"is",
"not",
">",
"2",
"if",
"EPEL6",
"template",
"will",
"be",
"used",
".",
"attributes",
"ba... | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/convertor.py#L81-L123 |
fedora-python/pyp2rpm | pyp2rpm/convertor.py | Convertor.convert | def convert(self):
"""Returns RPM SPECFILE.
Returns:
rendered RPM SPECFILE.
"""
# move file into position
try:
local_file = self.getter.get()
except (exceptions.NoSuchPackageException, OSError) as e:
logger.error(
"Faile... | python | def convert(self):
"""Returns RPM SPECFILE.
Returns:
rendered RPM SPECFILE.
"""
# move file into position
try:
local_file = self.getter.get()
except (exceptions.NoSuchPackageException, OSError) as e:
logger.error(
"Faile... | [
"def",
"convert",
"(",
"self",
")",
":",
"# move file into position",
"try",
":",
"local_file",
"=",
"self",
".",
"getter",
".",
"get",
"(",
")",
"except",
"(",
"exceptions",
".",
"NoSuchPackageException",
",",
"OSError",
")",
"as",
"e",
":",
"logger",
"."... | Returns RPM SPECFILE.
Returns:
rendered RPM SPECFILE. | [
"Returns",
"RPM",
"SPECFILE",
".",
"Returns",
":",
"rendered",
"RPM",
"SPECFILE",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/convertor.py#L125-L169 |
fedora-python/pyp2rpm | pyp2rpm/convertor.py | Convertor.getter | def getter(self):
"""Returns an instance of proper PackageGetter subclass. Always
returns the same instance.
Returns:
Instance of the proper PackageGetter subclass according to
provided argument.
Raises:
NoSuchSourceException if source to get the pack... | python | def getter(self):
"""Returns an instance of proper PackageGetter subclass. Always
returns the same instance.
Returns:
Instance of the proper PackageGetter subclass according to
provided argument.
Raises:
NoSuchSourceException if source to get the pack... | [
"def",
"getter",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_getter'",
")",
":",
"if",
"not",
"self",
".",
"pypi",
":",
"self",
".",
"_getter",
"=",
"package_getters",
".",
"LocalFileGetter",
"(",
"self",
".",
"package",
",",
... | Returns an instance of proper PackageGetter subclass. Always
returns the same instance.
Returns:
Instance of the proper PackageGetter subclass according to
provided argument.
Raises:
NoSuchSourceException if source to get the package from is unknown
... | [
"Returns",
"an",
"instance",
"of",
"proper",
"PackageGetter",
"subclass",
".",
"Always",
"returns",
"the",
"same",
"instance",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/convertor.py#L172-L198 |
fedora-python/pyp2rpm | pyp2rpm/convertor.py | Convertor.metadata_extractor | def metadata_extractor(self):
"""Returns an instance of proper MetadataExtractor subclass.
Always returns the same instance.
Returns:
The proper MetadataExtractor subclass according to local file
suffix.
"""
if not hasattr(self, '_local_file'):
... | python | def metadata_extractor(self):
"""Returns an instance of proper MetadataExtractor subclass.
Always returns the same instance.
Returns:
The proper MetadataExtractor subclass according to local file
suffix.
"""
if not hasattr(self, '_local_file'):
... | [
"def",
"metadata_extractor",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_local_file'",
")",
":",
"raise",
"AttributeError",
"(",
"\"local_file attribute must be set before \"",
"\"calling metadata_extractor\"",
")",
"if",
"not",
"hasattr",
"(",... | Returns an instance of proper MetadataExtractor subclass.
Always returns the same instance.
Returns:
The proper MetadataExtractor subclass according to local file
suffix. | [
"Returns",
"an",
"instance",
"of",
"proper",
"MetadataExtractor",
"subclass",
".",
"Always",
"returns",
"the",
"same",
"instance",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/convertor.py#L245-L278 |
fedora-python/pyp2rpm | pyp2rpm/convertor.py | Convertor.client | def client(self):
"""XMLRPC client for PyPI. Always returns the same instance.
If the package is provided as a path to compressed source file,
PyPI will not be used and the client will not be instantiated.
Returns:
XMLRPC client for PyPI or None.
"""
if self... | python | def client(self):
"""XMLRPC client for PyPI. Always returns the same instance.
If the package is provided as a path to compressed source file,
PyPI will not be used and the client will not be instantiated.
Returns:
XMLRPC client for PyPI or None.
"""
if self... | [
"def",
"client",
"(",
"self",
")",
":",
"if",
"self",
".",
"proxy",
":",
"proxyhandler",
"=",
"urllib",
".",
"ProxyHandler",
"(",
"{",
"\"http\"",
":",
"self",
".",
"proxy",
"}",
")",
"opener",
"=",
"urllib",
".",
"build_opener",
"(",
"proxyhandler",
"... | XMLRPC client for PyPI. Always returns the same instance.
If the package is provided as a path to compressed source file,
PyPI will not be used and the client will not be instantiated.
Returns:
XMLRPC client for PyPI or None. | [
"XMLRPC",
"client",
"for",
"PyPI",
".",
"Always",
"returns",
"the",
"same",
"instance",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/convertor.py#L281-L307 |
fedora-python/pyp2rpm | pyp2rpm/utils.py | memoize_by_args | def memoize_by_args(func):
"""Memoizes return value of a func based on args."""
memory = {}
@functools.wraps(func)
def memoized(*args):
if args not in memory.keys():
value = func(*args)
memory[args] = value
return memory[args]
return memoized | python | def memoize_by_args(func):
"""Memoizes return value of a func based on args."""
memory = {}
@functools.wraps(func)
def memoized(*args):
if args not in memory.keys():
value = func(*args)
memory[args] = value
return memory[args]
return memoized | [
"def",
"memoize_by_args",
"(",
"func",
")",
":",
"memory",
"=",
"{",
"}",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"memoized",
"(",
"*",
"args",
")",
":",
"if",
"args",
"not",
"in",
"memory",
".",
"keys",
"(",
")",
":",
"value",
"... | Memoizes return value of a func based on args. | [
"Memoizes",
"return",
"value",
"of",
"a",
"func",
"based",
"on",
"args",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/utils.py#L44-L56 |
fedora-python/pyp2rpm | pyp2rpm/utils.py | build_srpm | def build_srpm(specfile, save_dir):
"""Builds a srpm from given specfile using rpmbuild.
Generated srpm is stored in directory specified by save_dir.
Args:
specfile: path to a specfile
save_dir: path to source and build tree
"""
logger.info('Starting rpmbuild to build: {0} SRPM.'.fo... | python | def build_srpm(specfile, save_dir):
"""Builds a srpm from given specfile using rpmbuild.
Generated srpm is stored in directory specified by save_dir.
Args:
specfile: path to a specfile
save_dir: path to source and build tree
"""
logger.info('Starting rpmbuild to build: {0} SRPM.'.fo... | [
"def",
"build_srpm",
"(",
"specfile",
",",
"save_dir",
")",
":",
"logger",
".",
"info",
"(",
"'Starting rpmbuild to build: {0} SRPM.'",
".",
"format",
"(",
"specfile",
")",
")",
"if",
"save_dir",
"!=",
"get_default_save_path",
"(",
")",
":",
"try",
":",
"msg",... | Builds a srpm from given specfile using rpmbuild.
Generated srpm is stored in directory specified by save_dir.
Args:
specfile: path to a specfile
save_dir: path to source and build tree | [
"Builds",
"a",
"srpm",
"from",
"given",
"specfile",
"using",
"rpmbuild",
".",
"Generated",
"srpm",
"is",
"stored",
"in",
"directory",
"specified",
"by",
"save_dir",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/utils.py#L59-L101 |
fedora-python/pyp2rpm | pyp2rpm/utils.py | remove_major_minor_suffix | def remove_major_minor_suffix(scripts):
"""Checks if executables already contain a "-MAJOR.MINOR" suffix. """
minor_major_regex = re.compile("-\d.?\d?$")
return [x for x in scripts if not minor_major_regex.search(x)] | python | def remove_major_minor_suffix(scripts):
"""Checks if executables already contain a "-MAJOR.MINOR" suffix. """
minor_major_regex = re.compile("-\d.?\d?$")
return [x for x in scripts if not minor_major_regex.search(x)] | [
"def",
"remove_major_minor_suffix",
"(",
"scripts",
")",
":",
"minor_major_regex",
"=",
"re",
".",
"compile",
"(",
"\"-\\d.?\\d?$\"",
")",
"return",
"[",
"x",
"for",
"x",
"in",
"scripts",
"if",
"not",
"minor_major_regex",
".",
"search",
"(",
"x",
")",
"]"
] | Checks if executables already contain a "-MAJOR.MINOR" suffix. | [
"Checks",
"if",
"executables",
"already",
"contain",
"a",
"-",
"MAJOR",
".",
"MINOR",
"suffix",
"."
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/utils.py#L104-L107 |
fedora-python/pyp2rpm | pyp2rpm/utils.py | runtime_to_build | def runtime_to_build(runtime_deps):
"""Adds all runtime deps to build deps"""
build_deps = copy.deepcopy(runtime_deps)
for dep in build_deps:
if len(dep) > 0:
dep[0] = 'BuildRequires'
return build_deps | python | def runtime_to_build(runtime_deps):
"""Adds all runtime deps to build deps"""
build_deps = copy.deepcopy(runtime_deps)
for dep in build_deps:
if len(dep) > 0:
dep[0] = 'BuildRequires'
return build_deps | [
"def",
"runtime_to_build",
"(",
"runtime_deps",
")",
":",
"build_deps",
"=",
"copy",
".",
"deepcopy",
"(",
"runtime_deps",
")",
"for",
"dep",
"in",
"build_deps",
":",
"if",
"len",
"(",
"dep",
")",
">",
"0",
":",
"dep",
"[",
"0",
"]",
"=",
"'BuildRequir... | Adds all runtime deps to build deps | [
"Adds",
"all",
"runtime",
"deps",
"to",
"build",
"deps"
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/utils.py#L110-L116 |
fedora-python/pyp2rpm | pyp2rpm/utils.py | unique_deps | def unique_deps(deps):
"""Remove duplicities from deps list of the lists"""
deps.sort()
return list(k for k, _ in itertools.groupby(deps)) | python | def unique_deps(deps):
"""Remove duplicities from deps list of the lists"""
deps.sort()
return list(k for k, _ in itertools.groupby(deps)) | [
"def",
"unique_deps",
"(",
"deps",
")",
":",
"deps",
".",
"sort",
"(",
")",
"return",
"list",
"(",
"k",
"for",
"k",
",",
"_",
"in",
"itertools",
".",
"groupby",
"(",
"deps",
")",
")"
] | Remove duplicities from deps list of the lists | [
"Remove",
"duplicities",
"from",
"deps",
"list",
"of",
"the",
"lists"
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/utils.py#L119-L122 |
fedora-python/pyp2rpm | pyp2rpm/utils.py | c_time_locale | def c_time_locale():
"""Context manager with C LC_TIME locale"""
old_time_locale = locale.getlocale(locale.LC_TIME)
locale.setlocale(locale.LC_TIME, 'C')
yield
locale.setlocale(locale.LC_TIME, old_time_locale) | python | def c_time_locale():
"""Context manager with C LC_TIME locale"""
old_time_locale = locale.getlocale(locale.LC_TIME)
locale.setlocale(locale.LC_TIME, 'C')
yield
locale.setlocale(locale.LC_TIME, old_time_locale) | [
"def",
"c_time_locale",
"(",
")",
":",
"old_time_locale",
"=",
"locale",
".",
"getlocale",
"(",
"locale",
".",
"LC_TIME",
")",
"locale",
".",
"setlocale",
"(",
"locale",
".",
"LC_TIME",
",",
"'C'",
")",
"yield",
"locale",
".",
"setlocale",
"(",
"locale",
... | Context manager with C LC_TIME locale | [
"Context",
"manager",
"with",
"C",
"LC_TIME",
"locale"
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/utils.py#L137-L142 |
fedora-python/pyp2rpm | pyp2rpm/utils.py | rpm_eval | def rpm_eval(macro):
"""Get value of given macro using rpm tool"""
try:
value = subprocess.Popen(
['rpm', '--eval', macro],
stdout=subprocess.PIPE).communicate()[0].strip()
except OSError:
logger.error('Failed to get value of {0} rpm macro'.format(
macro),... | python | def rpm_eval(macro):
"""Get value of given macro using rpm tool"""
try:
value = subprocess.Popen(
['rpm', '--eval', macro],
stdout=subprocess.PIPE).communicate()[0].strip()
except OSError:
logger.error('Failed to get value of {0} rpm macro'.format(
macro),... | [
"def",
"rpm_eval",
"(",
"macro",
")",
":",
"try",
":",
"value",
"=",
"subprocess",
".",
"Popen",
"(",
"[",
"'rpm'",
",",
"'--eval'",
",",
"macro",
"]",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
")",
".",
"communicate",
"(",
")",
"[",
"0",
"]",... | Get value of given macro using rpm tool | [
"Get",
"value",
"of",
"given",
"macro",
"using",
"rpm",
"tool"
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/utils.py#L145-L155 |
fedora-python/pyp2rpm | pyp2rpm/utils.py | get_default_save_path | def get_default_save_path():
"""Return default save path for the packages"""
macro = '%{_topdir}'
if rpm:
save_path = rpm.expandMacro(macro)
else:
save_path = rpm_eval(macro)
if not save_path:
logger.warn("rpm tools are missing, using default save path "
... | python | def get_default_save_path():
"""Return default save path for the packages"""
macro = '%{_topdir}'
if rpm:
save_path = rpm.expandMacro(macro)
else:
save_path = rpm_eval(macro)
if not save_path:
logger.warn("rpm tools are missing, using default save path "
... | [
"def",
"get_default_save_path",
"(",
")",
":",
"macro",
"=",
"'%{_topdir}'",
"if",
"rpm",
":",
"save_path",
"=",
"rpm",
".",
"expandMacro",
"(",
"macro",
")",
"else",
":",
"save_path",
"=",
"rpm_eval",
"(",
"macro",
")",
"if",
"not",
"save_path",
":",
"l... | Return default save path for the packages | [
"Return",
"default",
"save",
"path",
"for",
"the",
"packages"
] | train | https://github.com/fedora-python/pyp2rpm/blob/853eb3d226689a5ccdcdb9358b1a3394fafbd2b5/pyp2rpm/utils.py#L158-L169 |
spacetelescope/drizzlepac | drizzlepac/alignimages.py | check_and_get_data | def check_and_get_data(input_list,**pars):
"""Verify that all specified files are present. If not, retrieve them from MAST.
Parameters
----------
input_list : list
List of one or more calibrated fits images that will be used for catalog generation.
Returns
=======
total_input_list:... | python | def check_and_get_data(input_list,**pars):
"""Verify that all specified files are present. If not, retrieve them from MAST.
Parameters
----------
input_list : list
List of one or more calibrated fits images that will be used for catalog generation.
Returns
=======
total_input_list:... | [
"def",
"check_and_get_data",
"(",
"input_list",
",",
"*",
"*",
"pars",
")",
":",
"empty_list",
"=",
"[",
"]",
"retrieve_list",
"=",
"[",
"]",
"# Actual files retrieved via astroquery and resident on disk",
"candidate_list",
"=",
"[",
"]",
"# File names gathered from *_a... | Verify that all specified files are present. If not, retrieve them from MAST.
Parameters
----------
input_list : list
List of one or more calibrated fits images that will be used for catalog generation.
Returns
=======
total_input_list: list
list of full filenames | [
"Verify",
"that",
"all",
"specified",
"files",
"are",
"present",
".",
"If",
"not",
"retrieve",
"them",
"from",
"MAST",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/alignimages.py#L78-L172 |
spacetelescope/drizzlepac | drizzlepac/alignimages.py | perform_align | def perform_align(input_list, **kwargs):
"""Main calling function.
Parameters
----------
input_list : list
List of one or more IPPSSOOTs (rootnames) to align.
archive : Boolean
Retain copies of the downloaded files in the astroquery created sub-directories?
clobber : Boolean
... | python | def perform_align(input_list, **kwargs):
"""Main calling function.
Parameters
----------
input_list : list
List of one or more IPPSSOOTs (rootnames) to align.
archive : Boolean
Retain copies of the downloaded files in the astroquery created sub-directories?
clobber : Boolean
... | [
"def",
"perform_align",
"(",
"input_list",
",",
"*",
"*",
"kwargs",
")",
":",
"filteredTable",
"=",
"Table",
"(",
")",
"run_align",
"(",
"input_list",
",",
"result",
"=",
"filteredTable",
",",
"*",
"*",
"kwargs",
")",
"return",
"filteredTable"
] | Main calling function.
Parameters
----------
input_list : list
List of one or more IPPSSOOTs (rootnames) to align.
archive : Boolean
Retain copies of the downloaded files in the astroquery created sub-directories?
clobber : Boolean
Download and overwrite existing local cop... | [
"Main",
"calling",
"function",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/alignimages.py#L175-L216 |
spacetelescope/drizzlepac | drizzlepac/alignimages.py | match_relative_fit | def match_relative_fit(imglist, reference_catalog):
"""Perform cross-matching and final fit using 2dHistogram matching
Parameters
----------
imglist : list
List of input image `~tweakwcs.tpwcs.FITSWCS` objects with metadata and source catalogs
reference_catalog : Table
Astropy Tabl... | python | def match_relative_fit(imglist, reference_catalog):
"""Perform cross-matching and final fit using 2dHistogram matching
Parameters
----------
imglist : list
List of input image `~tweakwcs.tpwcs.FITSWCS` objects with metadata and source catalogs
reference_catalog : Table
Astropy Tabl... | [
"def",
"match_relative_fit",
"(",
"imglist",
",",
"reference_catalog",
")",
":",
"log",
".",
"info",
"(",
"\"------------------- STEP 5b: (match_relative_fit) Cross matching and fitting ---------------------------\"",
")",
"# 0: Specify matching algorithm to use",
"match",
"=",
"tw... | Perform cross-matching and final fit using 2dHistogram matching
Parameters
----------
imglist : list
List of input image `~tweakwcs.tpwcs.FITSWCS` objects with metadata and source catalogs
reference_catalog : Table
Astropy Table of reference sources for this field
Returns
----... | [
"Perform",
"cross",
"-",
"matching",
"and",
"final",
"fit",
"using",
"2dHistogram",
"matching"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/alignimages.py#L558-L599 |
spacetelescope/drizzlepac | drizzlepac/alignimages.py | match_default_fit | def match_default_fit(imglist, reference_catalog):
"""Perform cross-matching and final fit using 2dHistogram matching
Parameters
----------
imglist : list
List of input image `~tweakwcs.tpwcs.FITSWCS` objects with metadata and source catalogs
reference_catalog : Table
Astropy Table... | python | def match_default_fit(imglist, reference_catalog):
"""Perform cross-matching and final fit using 2dHistogram matching
Parameters
----------
imglist : list
List of input image `~tweakwcs.tpwcs.FITSWCS` objects with metadata and source catalogs
reference_catalog : Table
Astropy Table... | [
"def",
"match_default_fit",
"(",
"imglist",
",",
"reference_catalog",
")",
":",
"log",
".",
"info",
"(",
"\"-------------------- STEP 5b: (match_default_fit) Cross matching and fitting ---------------------------\"",
")",
"# Specify matching algorithm to use",
"match",
"=",
"tweakw... | Perform cross-matching and final fit using 2dHistogram matching
Parameters
----------
imglist : list
List of input image `~tweakwcs.tpwcs.FITSWCS` objects with metadata and source catalogs
reference_catalog : Table
Astropy Table of reference sources for this field
Returns
----... | [
"Perform",
"cross",
"-",
"matching",
"and",
"final",
"fit",
"using",
"2dHistogram",
"matching"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/alignimages.py#L604-L631 |
spacetelescope/drizzlepac | drizzlepac/alignimages.py | determine_fit_quality | def determine_fit_quality(imglist,filteredTable, print_fit_parameters=True):
"""Determine the quality of the fit to the data
Parameters
----------
imglist : list
output of interpret_fits. Contains sourcelist tables, newly computed WCS info, etc. for every chip of every valid
input image... | python | def determine_fit_quality(imglist,filteredTable, print_fit_parameters=True):
"""Determine the quality of the fit to the data
Parameters
----------
imglist : list
output of interpret_fits. Contains sourcelist tables, newly computed WCS info, etc. for every chip of every valid
input image... | [
"def",
"determine_fit_quality",
"(",
"imglist",
",",
"filteredTable",
",",
"print_fit_parameters",
"=",
"True",
")",
":",
"tweakwcs_info_keys",
"=",
"OrderedDict",
"(",
"imglist",
"[",
"0",
"]",
".",
"meta",
"[",
"'fit_info'",
"]",
")",
".",
"keys",
"(",
")"... | Determine the quality of the fit to the data
Parameters
----------
imglist : list
output of interpret_fits. Contains sourcelist tables, newly computed WCS info, etc. for every chip of every valid
input image. This list should have been updated, in-place, with the new RMS values;
s... | [
"Determine",
"the",
"quality",
"of",
"the",
"fit",
"to",
"the",
"data"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/alignimages.py#L670-L862 |
spacetelescope/drizzlepac | drizzlepac/alignimages.py | generate_astrometric_catalog | def generate_astrometric_catalog(imglist, **pars):
"""Generates a catalog of all sources from an existing astrometric catalog are in or near the FOVs of the images in
the input list.
Parameters
----------
imglist : list
List of one or more calibrated fits images that will be used for ca... | python | def generate_astrometric_catalog(imglist, **pars):
"""Generates a catalog of all sources from an existing astrometric catalog are in or near the FOVs of the images in
the input list.
Parameters
----------
imglist : list
List of one or more calibrated fits images that will be used for ca... | [
"def",
"generate_astrometric_catalog",
"(",
"imglist",
",",
"*",
"*",
"pars",
")",
":",
"# generate catalog",
"temp_pars",
"=",
"pars",
".",
"copy",
"(",
")",
"if",
"pars",
"[",
"'output'",
"]",
"==",
"True",
":",
"pars",
"[",
"'output'",
"]",
"=",
"'ref... | Generates a catalog of all sources from an existing astrometric catalog are in or near the FOVs of the images in
the input list.
Parameters
----------
imglist : list
List of one or more calibrated fits images that will be used for catalog generation.
Returns
=======
ref_table :... | [
"Generates",
"a",
"catalog",
"of",
"all",
"sources",
"from",
"an",
"existing",
"astrometric",
"catalog",
"are",
"in",
"or",
"near",
"the",
"FOVs",
"of",
"the",
"images",
"in",
"the",
"input",
"list",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/alignimages.py#L868-L897 |
spacetelescope/drizzlepac | drizzlepac/alignimages.py | generate_source_catalogs | def generate_source_catalogs(imglist, **pars):
"""Generates a dictionary of source catalogs keyed by image name.
Parameters
----------
imglist : list
List of one or more calibrated fits images that will be used for source detection.
Returns
-------
sourcecatalogdict : dictionary
... | python | def generate_source_catalogs(imglist, **pars):
"""Generates a dictionary of source catalogs keyed by image name.
Parameters
----------
imglist : list
List of one or more calibrated fits images that will be used for source detection.
Returns
-------
sourcecatalogdict : dictionary
... | [
"def",
"generate_source_catalogs",
"(",
"imglist",
",",
"*",
"*",
"pars",
")",
":",
"output",
"=",
"pars",
".",
"get",
"(",
"'output'",
",",
"False",
")",
"sourcecatalogdict",
"=",
"{",
"}",
"for",
"imgname",
"in",
"imglist",
":",
"log",
".",
"info",
"... | Generates a dictionary of source catalogs keyed by image name.
Parameters
----------
imglist : list
List of one or more calibrated fits images that will be used for source detection.
Returns
-------
sourcecatalogdict : dictionary
a dictionary (keyed by image name) of two elemen... | [
"Generates",
"a",
"dictionary",
"of",
"source",
"catalogs",
"keyed",
"by",
"image",
"name",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/alignimages.py#L903-L964 |
spacetelescope/drizzlepac | drizzlepac/alignimages.py | update_image_wcs_info | def update_image_wcs_info(tweakwcs_output):
"""Write newly computed WCS information to image headers and write headerlet files
Parameters
----------
tweakwcs_output : list
output of tweakwcs. Contains sourcelist tables, newly computed WCS info, etc. for every chip of every valid... | python | def update_image_wcs_info(tweakwcs_output):
"""Write newly computed WCS information to image headers and write headerlet files
Parameters
----------
tweakwcs_output : list
output of tweakwcs. Contains sourcelist tables, newly computed WCS info, etc. for every chip of every valid... | [
"def",
"update_image_wcs_info",
"(",
"tweakwcs_output",
")",
":",
"out_headerlet_dict",
"=",
"{",
"}",
"for",
"item",
"in",
"tweakwcs_output",
":",
"imageName",
"=",
"item",
".",
"meta",
"[",
"'filename'",
"]",
"chipnum",
"=",
"item",
".",
"meta",
"[",
"'chi... | Write newly computed WCS information to image headers and write headerlet files
Parameters
----------
tweakwcs_output : list
output of tweakwcs. Contains sourcelist tables, newly computed WCS info, etc. for every chip of every valid
input image.
Returns
... | [
"Write",
"newly",
"computed",
"WCS",
"information",
"to",
"image",
"headers",
"and",
"write",
"headerlet",
"files"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/alignimages.py#L970-L1036 |
spacetelescope/drizzlepac | drizzlepac/alignimages.py | update_headerlet_phdu | def update_headerlet_phdu(tweakwcs_item, headerlet):
"""Update the primary header data unit keywords of a headerlet object in-place
Parameters
==========
tweakwc_item :
Basically the output from tweakwcs which contains the cross match and fit
information for every chip of every valid in... | python | def update_headerlet_phdu(tweakwcs_item, headerlet):
"""Update the primary header data unit keywords of a headerlet object in-place
Parameters
==========
tweakwc_item :
Basically the output from tweakwcs which contains the cross match and fit
information for every chip of every valid in... | [
"def",
"update_headerlet_phdu",
"(",
"tweakwcs_item",
",",
"headerlet",
")",
":",
"# Get the data to be used as values for FITS keywords",
"rms_ra",
"=",
"tweakwcs_item",
".",
"meta",
"[",
"'fit_info'",
"]",
"[",
"'RMS_RA'",
"]",
".",
"value",
"rms_dec",
"=",
"tweakwc... | Update the primary header data unit keywords of a headerlet object in-place
Parameters
==========
tweakwc_item :
Basically the output from tweakwcs which contains the cross match and fit
information for every chip of every valid input image.
headerlet :
object containing WCS in... | [
"Update",
"the",
"primary",
"header",
"data",
"unit",
"keywords",
"of",
"a",
"headerlet",
"object",
"in",
"-",
"place"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/alignimages.py#L1040-L1083 |
spacetelescope/drizzlepac | drizzlepac/alignimages.py | interpret_fit_rms | def interpret_fit_rms(tweakwcs_output, reference_catalog):
"""Interpret the FIT information to convert RMS to physical units
Parameters
----------
tweakwcs_output : list
output of tweakwcs. Contains sourcelist tables, newly computed WCS info, etc. for every chip of every valid
input ima... | python | def interpret_fit_rms(tweakwcs_output, reference_catalog):
"""Interpret the FIT information to convert RMS to physical units
Parameters
----------
tweakwcs_output : list
output of tweakwcs. Contains sourcelist tables, newly computed WCS info, etc. for every chip of every valid
input ima... | [
"def",
"interpret_fit_rms",
"(",
"tweakwcs_output",
",",
"reference_catalog",
")",
":",
"# Start by collecting information by group_id",
"group_ids",
"=",
"[",
"info",
".",
"meta",
"[",
"'group_id'",
"]",
"for",
"info",
"in",
"tweakwcs_output",
"]",
"# Compress the list... | Interpret the FIT information to convert RMS to physical units
Parameters
----------
tweakwcs_output : list
output of tweakwcs. Contains sourcelist tables, newly computed WCS info, etc. for every chip of every valid
input image. This list gets updated, in-place, with the new RMS values;
... | [
"Interpret",
"the",
"FIT",
"information",
"to",
"convert",
"RMS",
"to",
"physical",
"units"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/alignimages.py#L1089-L1170 |
spacetelescope/drizzlepac | drizzlepac/sky.py | sky | def sky(input=None,outExt=None,configObj=None, group=None, editpars=False, **inputDict):
"""
Perform sky subtraction on input list of images
Parameters
----------
input : str or list of str
a python list of image filenames, or just a single filename
configObj : configObject
an i... | python | def sky(input=None,outExt=None,configObj=None, group=None, editpars=False, **inputDict):
"""
Perform sky subtraction on input list of images
Parameters
----------
input : str or list of str
a python list of image filenames, or just a single filename
configObj : configObject
an i... | [
"def",
"sky",
"(",
"input",
"=",
"None",
",",
"outExt",
"=",
"None",
",",
"configObj",
"=",
"None",
",",
"group",
"=",
"None",
",",
"editpars",
"=",
"False",
",",
"*",
"*",
"inputDict",
")",
":",
"if",
"input",
"is",
"not",
"None",
":",
"inputDict"... | Perform sky subtraction on input list of images
Parameters
----------
input : str or list of str
a python list of image filenames, or just a single filename
configObj : configObject
an instance of configObject
inputDict : dict, optional
an optional list of parameters specifi... | [
"Perform",
"sky",
"subtraction",
"on",
"input",
"list",
"of",
"images"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/sky.py#L43-L107 |
spacetelescope/drizzlepac | drizzlepac/sky.py | _skyUserFromFile | def _skyUserFromFile(imageObjList, skyFile, apply_sky=None):
"""
Apply sky value as read in from a user-supplied input file.
"""
skyKW="MDRIZSKY" #header keyword that contains the sky that's been subtracted
# create dict of fname=sky pairs
skyvals = {}
if apply_sky is None:
skyappl... | python | def _skyUserFromFile(imageObjList, skyFile, apply_sky=None):
"""
Apply sky value as read in from a user-supplied input file.
"""
skyKW="MDRIZSKY" #header keyword that contains the sky that's been subtracted
# create dict of fname=sky pairs
skyvals = {}
if apply_sky is None:
skyappl... | [
"def",
"_skyUserFromFile",
"(",
"imageObjList",
",",
"skyFile",
",",
"apply_sky",
"=",
"None",
")",
":",
"skyKW",
"=",
"\"MDRIZSKY\"",
"#header keyword that contains the sky that's been subtracted",
"# create dict of fname=sky pairs",
"skyvals",
"=",
"{",
"}",
"if",
"appl... | Apply sky value as read in from a user-supplied input file. | [
"Apply",
"sky",
"value",
"as",
"read",
"in",
"from",
"a",
"user",
"-",
"supplied",
"input",
"file",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/sky.py#L453-L518 |
spacetelescope/drizzlepac | drizzlepac/sky.py | _skyUserFromHeaderKwd | def _skyUserFromHeaderKwd(imageSet,paramDict):
"""
subtract the sky from all the chips in the imagefile that imageSet represents
imageSet is a single imageObject reference
paramDict should be the subset from an actual config object
"""
_skyValue=0.0 #this will be the sky value computed for ... | python | def _skyUserFromHeaderKwd(imageSet,paramDict):
"""
subtract the sky from all the chips in the imagefile that imageSet represents
imageSet is a single imageObject reference
paramDict should be the subset from an actual config object
"""
_skyValue=0.0 #this will be the sky value computed for ... | [
"def",
"_skyUserFromHeaderKwd",
"(",
"imageSet",
",",
"paramDict",
")",
":",
"_skyValue",
"=",
"0.0",
"#this will be the sky value computed for the exposure",
"skyKW",
"=",
"\"MDRIZSKY\"",
"#header keyword that contains the sky that's been subtracted",
"#just making sure, tricky user... | subtract the sky from all the chips in the imagefile that imageSet represents
imageSet is a single imageObject reference
paramDict should be the subset from an actual config object | [
"subtract",
"the",
"sky",
"from",
"all",
"the",
"chips",
"in",
"the",
"imagefile",
"that",
"imageSet",
"represents"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/sky.py#L520-L575 |
spacetelescope/drizzlepac | drizzlepac/sky.py | _skySub | def _skySub(imageSet,paramDict,saveFile=False):
"""
subtract the sky from all the chips in the imagefile that imageSet represents
imageSet is a single imageObject reference
paramDict should be the subset from an actual config object
if saveFile=True, then images that have been sky subtracted are sa... | python | def _skySub(imageSet,paramDict,saveFile=False):
"""
subtract the sky from all the chips in the imagefile that imageSet represents
imageSet is a single imageObject reference
paramDict should be the subset from an actual config object
if saveFile=True, then images that have been sky subtracted are sa... | [
"def",
"_skySub",
"(",
"imageSet",
",",
"paramDict",
",",
"saveFile",
"=",
"False",
")",
":",
"_skyValue",
"=",
"0.0",
"#this will be the sky value computed for the exposure",
"skyKW",
"=",
"\"MDRIZSKY\"",
"#header keyword that contains the sky that's been subtracted",
"#just... | subtract the sky from all the chips in the imagefile that imageSet represents
imageSet is a single imageObject reference
paramDict should be the subset from an actual config object
if saveFile=True, then images that have been sky subtracted are saved to a predetermined output name
else, overwrite the i... | [
"subtract",
"the",
"sky",
"from",
"all",
"the",
"chips",
"in",
"the",
"imagefile",
"that",
"imageSet",
"represents"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/sky.py#L581-L692 |
spacetelescope/drizzlepac | drizzlepac/sky.py | _computeSky | def _computeSky(image, skypars, memmap=False):
"""
Compute the sky value for the data array passed to the function
image is a fits object which contains the data and the header
for one image extension
skypars is passed in as paramDict
"""
#this object contains the returned values from the... | python | def _computeSky(image, skypars, memmap=False):
"""
Compute the sky value for the data array passed to the function
image is a fits object which contains the data and the header
for one image extension
skypars is passed in as paramDict
"""
#this object contains the returned values from the... | [
"def",
"_computeSky",
"(",
"image",
",",
"skypars",
",",
"memmap",
"=",
"False",
")",
":",
"#this object contains the returned values from the image stats routine",
"_tmp",
"=",
"imagestats",
".",
"ImageStats",
"(",
"image",
".",
"data",
",",
"fields",
"=",
"skypars... | Compute the sky value for the data array passed to the function
image is a fits object which contains the data and the header
for one image extension
skypars is passed in as paramDict | [
"Compute",
"the",
"sky",
"value",
"for",
"the",
"data",
"array",
"passed",
"to",
"the",
"function",
"image",
"is",
"a",
"fits",
"object",
"which",
"contains",
"the",
"data",
"and",
"the",
"header",
"for",
"one",
"image",
"extension"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/sky.py#L699-L726 |
spacetelescope/drizzlepac | drizzlepac/sky.py | _subtractSky | def _subtractSky(image,skyValue,memmap=False):
"""
subtract the given sky value from each the data array
that has been passed. image is a fits object that
contains the data and header for one image extension
"""
try:
np.subtract(image.data,skyValue,image.data)
except IOError:
... | python | def _subtractSky(image,skyValue,memmap=False):
"""
subtract the given sky value from each the data array
that has been passed. image is a fits object that
contains the data and header for one image extension
"""
try:
np.subtract(image.data,skyValue,image.data)
except IOError:
... | [
"def",
"_subtractSky",
"(",
"image",
",",
"skyValue",
",",
"memmap",
"=",
"False",
")",
":",
"try",
":",
"np",
".",
"subtract",
"(",
"image",
".",
"data",
",",
"skyValue",
",",
"image",
".",
"data",
")",
"except",
"IOError",
":",
"print",
"(",
"\"Una... | subtract the given sky value from each the data array
that has been passed. image is a fits object that
contains the data and header for one image extension | [
"subtract",
"the",
"given",
"sky",
"value",
"from",
"each",
"the",
"data",
"array",
"that",
"has",
"been",
"passed",
".",
"image",
"is",
"a",
"fits",
"object",
"that",
"contains",
"the",
"data",
"and",
"header",
"for",
"one",
"image",
"extension"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/sky.py#L740-L751 |
spacetelescope/drizzlepac | drizzlepac/sky.py | _updateKW | def _updateKW(image, filename, exten, skyKW, Value):
"""update the header with the kw,value"""
# Update the value in memory
image.header[skyKW] = Value
# Now update the value on disk
if isinstance(exten,tuple):
strexten = '[%s,%s]'%(exten[0],str(exten[1]))
else:
strexten = '[%s]... | python | def _updateKW(image, filename, exten, skyKW, Value):
"""update the header with the kw,value"""
# Update the value in memory
image.header[skyKW] = Value
# Now update the value on disk
if isinstance(exten,tuple):
strexten = '[%s,%s]'%(exten[0],str(exten[1]))
else:
strexten = '[%s]... | [
"def",
"_updateKW",
"(",
"image",
",",
"filename",
",",
"exten",
",",
"skyKW",
",",
"Value",
")",
":",
"# Update the value in memory",
"image",
".",
"header",
"[",
"skyKW",
"]",
"=",
"Value",
"# Now update the value on disk",
"if",
"isinstance",
"(",
"exten",
... | update the header with the kw,value | [
"update",
"the",
"header",
"with",
"the",
"kw",
"value"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/sky.py#L754-L767 |
spacetelescope/drizzlepac | drizzlepac/sky.py | _addDefaultSkyKW | def _addDefaultSkyKW(imageObjList):
"""Add MDRIZSKY keyword to "commanded" SCI headers of all input images,
if that keyword does not already exist.
"""
skyKW = "MDRIZSKY"
Value = 0.0
for imageSet in imageObjList:
fname = imageSet._filename
numchips=imageSet._numchips
... | python | def _addDefaultSkyKW(imageObjList):
"""Add MDRIZSKY keyword to "commanded" SCI headers of all input images,
if that keyword does not already exist.
"""
skyKW = "MDRIZSKY"
Value = 0.0
for imageSet in imageObjList:
fname = imageSet._filename
numchips=imageSet._numchips
... | [
"def",
"_addDefaultSkyKW",
"(",
"imageObjList",
")",
":",
"skyKW",
"=",
"\"MDRIZSKY\"",
"Value",
"=",
"0.0",
"for",
"imageSet",
"in",
"imageObjList",
":",
"fname",
"=",
"imageSet",
".",
"_filename",
"numchips",
"=",
"imageSet",
".",
"_numchips",
"sciExt",
"=",... | Add MDRIZSKY keyword to "commanded" SCI headers of all input images,
if that keyword does not already exist. | [
"Add",
"MDRIZSKY",
"keyword",
"to",
"commanded",
"SCI",
"headers",
"of",
"all",
"input",
"images",
"if",
"that",
"keyword",
"does",
"not",
"already",
"exist",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/sky.py#L769-L790 |
spacetelescope/drizzlepac | drizzlepac/sky.py | help | def help(file=None):
"""
Print out syntax help for running astrodrizzle
Parameters
----------
file : str (Default = None)
If given, write out help to the filename specified by this parameter
Any previously existing file with this name will be deleted before
writing out the h... | python | def help(file=None):
"""
Print out syntax help for running astrodrizzle
Parameters
----------
file : str (Default = None)
If given, write out help to the filename specified by this parameter
Any previously existing file with this name will be deleted before
writing out the h... | [
"def",
"help",
"(",
"file",
"=",
"None",
")",
":",
"helpstr",
"=",
"getHelpAsString",
"(",
"docstring",
"=",
"True",
",",
"show_ver",
"=",
"True",
")",
"if",
"file",
"is",
"None",
":",
"print",
"(",
"helpstr",
")",
"else",
":",
"if",
"os",
".",
"pa... | Print out syntax help for running astrodrizzle
Parameters
----------
file : str (Default = None)
If given, write out help to the filename specified by this parameter
Any previously existing file with this name will be deleted before
writing out the help. | [
"Print",
"out",
"syntax",
"help",
"for",
"running",
"astrodrizzle"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/sky.py#L803-L822 |
spacetelescope/drizzlepac | drizzlepac/skytopix.py | rd2xy | def rd2xy(input,ra=None,dec=None,coordfile=None,colnames=None,
precision=6,output=None,verbose=True):
""" Primary interface to perform coordinate transformations from
pixel to sky coordinates using STWCS and full distortion models
read from the input image header.
"""
single_coor... | python | def rd2xy(input,ra=None,dec=None,coordfile=None,colnames=None,
precision=6,output=None,verbose=True):
""" Primary interface to perform coordinate transformations from
pixel to sky coordinates using STWCS and full distortion models
read from the input image header.
"""
single_coor... | [
"def",
"rd2xy",
"(",
"input",
",",
"ra",
"=",
"None",
",",
"dec",
"=",
"None",
",",
"coordfile",
"=",
"None",
",",
"colnames",
"=",
"None",
",",
"precision",
"=",
"6",
",",
"output",
"=",
"None",
",",
"verbose",
"=",
"True",
")",
":",
"single_coord... | Primary interface to perform coordinate transformations from
pixel to sky coordinates using STWCS and full distortion models
read from the input image header. | [
"Primary",
"interface",
"to",
"perform",
"coordinate",
"transformations",
"from",
"pixel",
"to",
"sky",
"coordinates",
"using",
"STWCS",
"and",
"full",
"distortion",
"models",
"read",
"from",
"the",
"input",
"image",
"header",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/skytopix.py#L90-L162 |
spacetelescope/drizzlepac | drizzlepac/hlautils/astrometric_utils.py | create_astrometric_catalog | def create_astrometric_catalog(inputs, **pars):
"""Create an astrometric catalog that covers the inputs' field-of-view.
Parameters
----------
input : str, list
Filenames of images to be aligned to astrometric catalog
catalog : str, optional
Name of catalog to extract astrometric po... | python | def create_astrometric_catalog(inputs, **pars):
"""Create an astrometric catalog that covers the inputs' field-of-view.
Parameters
----------
input : str, list
Filenames of images to be aligned to astrometric catalog
catalog : str, optional
Name of catalog to extract astrometric po... | [
"def",
"create_astrometric_catalog",
"(",
"inputs",
",",
"*",
"*",
"pars",
")",
":",
"# interpret input parameters",
"catalog",
"=",
"pars",
".",
"get",
"(",
"\"catalog\"",
",",
"'GAIADR2'",
")",
"output",
"=",
"pars",
".",
"get",
"(",
"\"output\"",
",",
"'r... | Create an astrometric catalog that covers the inputs' field-of-view.
Parameters
----------
input : str, list
Filenames of images to be aligned to astrometric catalog
catalog : str, optional
Name of catalog to extract astrometric positions for sources in the
input images' field-... | [
"Create",
"an",
"astrometric",
"catalog",
"that",
"covers",
"the",
"inputs",
"field",
"-",
"of",
"-",
"view",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/hlautils/astrometric_utils.py#L94-L184 |
spacetelescope/drizzlepac | drizzlepac/hlautils/astrometric_utils.py | build_reference_wcs | def build_reference_wcs(inputs, sciname='sci'):
"""Create the reference WCS based on all the inputs for a field"""
# start by creating a composite field-of-view for all inputs
wcslist = []
for img in inputs:
nsci = countExtn(img)
for num in range(nsci):
extname = (sciname, nu... | python | def build_reference_wcs(inputs, sciname='sci'):
"""Create the reference WCS based on all the inputs for a field"""
# start by creating a composite field-of-view for all inputs
wcslist = []
for img in inputs:
nsci = countExtn(img)
for num in range(nsci):
extname = (sciname, nu... | [
"def",
"build_reference_wcs",
"(",
"inputs",
",",
"sciname",
"=",
"'sci'",
")",
":",
"# start by creating a composite field-of-view for all inputs",
"wcslist",
"=",
"[",
"]",
"for",
"img",
"in",
"inputs",
":",
"nsci",
"=",
"countExtn",
"(",
"img",
")",
"for",
"n... | Create the reference WCS based on all the inputs for a field | [
"Create",
"the",
"reference",
"WCS",
"based",
"on",
"all",
"the",
"inputs",
"for",
"a",
"field"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/hlautils/astrometric_utils.py#L187-L209 |
spacetelescope/drizzlepac | drizzlepac/hlautils/astrometric_utils.py | get_catalog | def get_catalog(ra, dec, sr=0.1, fmt='CSV', catalog='GSC241'):
""" Extract catalog from VO web service.
Parameters
----------
ra : float
Right Ascension (RA) of center of field-of-view (in decimal degrees)
dec : float
Declination (Dec) of center of field-of-view (in decimal degrees... | python | def get_catalog(ra, dec, sr=0.1, fmt='CSV', catalog='GSC241'):
""" Extract catalog from VO web service.
Parameters
----------
ra : float
Right Ascension (RA) of center of field-of-view (in decimal degrees)
dec : float
Declination (Dec) of center of field-of-view (in decimal degrees... | [
"def",
"get_catalog",
"(",
"ra",
",",
"dec",
",",
"sr",
"=",
"0.1",
",",
"fmt",
"=",
"'CSV'",
",",
"catalog",
"=",
"'GSC241'",
")",
":",
"serviceType",
"=",
"'vo/CatalogSearch.aspx'",
"spec_str",
"=",
"'RA={}&DEC={}&SR={}&FORMAT={}&CAT={}&MINDET=5'",
"headers",
... | Extract catalog from VO web service.
Parameters
----------
ra : float
Right Ascension (RA) of center of field-of-view (in decimal degrees)
dec : float
Declination (Dec) of center of field-of-view (in decimal degrees)
sr : float, optional
Search radius (in decimal degrees) ... | [
"Extract",
"catalog",
"from",
"VO",
"web",
"service",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/hlautils/astrometric_utils.py#L212-L255 |
spacetelescope/drizzlepac | drizzlepac/hlautils/astrometric_utils.py | compute_radius | def compute_radius(wcs):
"""Compute the radius from the center to the furthest edge of the WCS."""
ra, dec = wcs.wcs.crval
img_center = SkyCoord(ra=ra * u.degree, dec=dec * u.degree)
wcs_foot = wcs.calc_footprint()
img_corners = SkyCoord(ra=wcs_foot[:, 0] * u.degree,
dec=... | python | def compute_radius(wcs):
"""Compute the radius from the center to the furthest edge of the WCS."""
ra, dec = wcs.wcs.crval
img_center = SkyCoord(ra=ra * u.degree, dec=dec * u.degree)
wcs_foot = wcs.calc_footprint()
img_corners = SkyCoord(ra=wcs_foot[:, 0] * u.degree,
dec=... | [
"def",
"compute_radius",
"(",
"wcs",
")",
":",
"ra",
",",
"dec",
"=",
"wcs",
".",
"wcs",
".",
"crval",
"img_center",
"=",
"SkyCoord",
"(",
"ra",
"=",
"ra",
"*",
"u",
".",
"degree",
",",
"dec",
"=",
"dec",
"*",
"u",
".",
"degree",
")",
"wcs_foot",... | Compute the radius from the center to the furthest edge of the WCS. | [
"Compute",
"the",
"radius",
"from",
"the",
"center",
"to",
"the",
"furthest",
"edge",
"of",
"the",
"WCS",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/hlautils/astrometric_utils.py#L258-L268 |
spacetelescope/drizzlepac | drizzlepac/hlautils/astrometric_utils.py | find_gsc_offset | def find_gsc_offset(image, input_catalog='GSC1', output_catalog='GAIA'):
"""Find the GSC to GAIA offset based on guide star coordinates
Parameters
----------
image : str
Filename of image to be processed.
Returns
-------
delta_ra, delta_dec : tuple of floats
Offset in decim... | python | def find_gsc_offset(image, input_catalog='GSC1', output_catalog='GAIA'):
"""Find the GSC to GAIA offset based on guide star coordinates
Parameters
----------
image : str
Filename of image to be processed.
Returns
-------
delta_ra, delta_dec : tuple of floats
Offset in decim... | [
"def",
"find_gsc_offset",
"(",
"image",
",",
"input_catalog",
"=",
"'GSC1'",
",",
"output_catalog",
"=",
"'GAIA'",
")",
":",
"serviceType",
"=",
"\"GSCConvert/GSCconvert.aspx\"",
"spec_str",
"=",
"\"TRANSFORM={}-{}&IPPPSSOOT={}\"",
"if",
"'rootname'",
"in",
"pf",
".",... | Find the GSC to GAIA offset based on guide star coordinates
Parameters
----------
image : str
Filename of image to be processed.
Returns
-------
delta_ra, delta_dec : tuple of floats
Offset in decimal degrees of image based on correction to guide star
coordinates relati... | [
"Find",
"the",
"GSC",
"to",
"GAIA",
"offset",
"based",
"on",
"guide",
"star",
"coordinates"
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/hlautils/astrometric_utils.py#L271-L308 |
spacetelescope/drizzlepac | drizzlepac/hlautils/astrometric_utils.py | extract_sources | def extract_sources(img, **pars):
"""Use photutils to find sources in image based on segmentation.
Parameters
----------
dqmask : ndarray
Bitmask which identifies whether a pixel should be used (1) in source
identification or not(0). If provided, this mask will be applied to the
... | python | def extract_sources(img, **pars):
"""Use photutils to find sources in image based on segmentation.
Parameters
----------
dqmask : ndarray
Bitmask which identifies whether a pixel should be used (1) in source
identification or not(0). If provided, this mask will be applied to the
... | [
"def",
"extract_sources",
"(",
"img",
",",
"*",
"*",
"pars",
")",
":",
"fwhm",
"=",
"pars",
".",
"get",
"(",
"'fwhm'",
",",
"3.0",
")",
"threshold",
"=",
"pars",
".",
"get",
"(",
"'threshold'",
",",
"None",
")",
"source_box",
"=",
"pars",
".",
"get... | Use photutils to find sources in image based on segmentation.
Parameters
----------
dqmask : ndarray
Bitmask which identifies whether a pixel should be used (1) in source
identification or not(0). If provided, this mask will be applied to the
input array prior to source identificati... | [
"Use",
"photutils",
"to",
"find",
"sources",
"in",
"image",
"based",
"on",
"segmentation",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/hlautils/astrometric_utils.py#L311-L510 |
spacetelescope/drizzlepac | drizzlepac/hlautils/astrometric_utils.py | classify_sources | def classify_sources(catalog, sources=None):
""" Convert moments_central attribute for source catalog into star/cr flag.
This algorithm interprets the central_moments from the source_properties
generated for the sources as more-likely a star or a cosmic-ray. It is not
intended or expected to be precis... | python | def classify_sources(catalog, sources=None):
""" Convert moments_central attribute for source catalog into star/cr flag.
This algorithm interprets the central_moments from the source_properties
generated for the sources as more-likely a star or a cosmic-ray. It is not
intended or expected to be precis... | [
"def",
"classify_sources",
"(",
"catalog",
",",
"sources",
"=",
"None",
")",
":",
"moments",
"=",
"catalog",
".",
"moments_central",
"if",
"sources",
"is",
"None",
":",
"sources",
"=",
"(",
"0",
",",
"len",
"(",
"moments",
")",
")",
"num_sources",
"=",
... | Convert moments_central attribute for source catalog into star/cr flag.
This algorithm interprets the central_moments from the source_properties
generated for the sources as more-likely a star or a cosmic-ray. It is not
intended or expected to be precise, merely a means of making a first cut at
removi... | [
"Convert",
"moments_central",
"attribute",
"for",
"source",
"catalog",
"into",
"star",
"/",
"cr",
"flag",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/hlautils/astrometric_utils.py#L513-L551 |
spacetelescope/drizzlepac | drizzlepac/hlautils/astrometric_utils.py | generate_source_catalog | def generate_source_catalog(image, **kwargs):
""" Build source catalogs for each chip using photutils.
The catalog returned by this function includes sources found in all chips
of the input image with the positions translated to the coordinate frame
defined by the reference WCS `refwcs`. The sources w... | python | def generate_source_catalog(image, **kwargs):
""" Build source catalogs for each chip using photutils.
The catalog returned by this function includes sources found in all chips
of the input image with the positions translated to the coordinate frame
defined by the reference WCS `refwcs`. The sources w... | [
"def",
"generate_source_catalog",
"(",
"image",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"image",
",",
"pf",
".",
"HDUList",
")",
":",
"raise",
"ValueError",
"(",
"\"Input {} not fits.HDUList object\"",
".",
"format",
"(",
"image",
... | Build source catalogs for each chip using photutils.
The catalog returned by this function includes sources found in all chips
of the input image with the positions translated to the coordinate frame
defined by the reference WCS `refwcs`. The sources will be
- identified using photutils segmentation-b... | [
"Build",
"source",
"catalogs",
"for",
"each",
"chip",
"using",
"photutils",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/hlautils/astrometric_utils.py#L554-L645 |
spacetelescope/drizzlepac | drizzlepac/hlautils/astrometric_utils.py | generate_sky_catalog | def generate_sky_catalog(image, refwcs, **kwargs):
"""Build source catalog from input image using photutils.
This script borrows heavily from build_source_catalog.
The catalog returned by this function includes sources found in all chips
of the input image with the positions translated to the coordina... | python | def generate_sky_catalog(image, refwcs, **kwargs):
"""Build source catalog from input image using photutils.
This script borrows heavily from build_source_catalog.
The catalog returned by this function includes sources found in all chips
of the input image with the positions translated to the coordina... | [
"def",
"generate_sky_catalog",
"(",
"image",
",",
"refwcs",
",",
"*",
"*",
"kwargs",
")",
":",
"# Extract source catalogs for each chip",
"source_cats",
"=",
"generate_source_catalog",
"(",
"image",
",",
"*",
"*",
"kwargs",
")",
"# Build source catalog for entire image"... | Build source catalog from input image using photutils.
This script borrows heavily from build_source_catalog.
The catalog returned by this function includes sources found in all chips
of the input image with the positions translated to the coordinate frame
defined by the reference WCS `refwcs`. The s... | [
"Build",
"source",
"catalog",
"from",
"input",
"image",
"using",
"photutils",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/hlautils/astrometric_utils.py#L648-L723 |
spacetelescope/drizzlepac | drizzlepac/hlautils/astrometric_utils.py | compute_photometry | def compute_photometry(catalog, photmode):
""" Compute magnitudes for sources from catalog based on observations photmode.
Parameters
----------
catalog : `~astropy.table.Table`
Astropy Table with 'source_sum' column for the measured flux for each source.
photmode : str
Specificati... | python | def compute_photometry(catalog, photmode):
""" Compute magnitudes for sources from catalog based on observations photmode.
Parameters
----------
catalog : `~astropy.table.Table`
Astropy Table with 'source_sum' column for the measured flux for each source.
photmode : str
Specificati... | [
"def",
"compute_photometry",
"(",
"catalog",
",",
"photmode",
")",
":",
"# Determine VEGAMAG zero-point using pysynphot for this photmode",
"photmode",
"=",
"photmode",
".",
"replace",
"(",
"' '",
",",
"', '",
")",
"vega",
"=",
"S",
".",
"FileSpectrum",
"(",
"VEGASP... | Compute magnitudes for sources from catalog based on observations photmode.
Parameters
----------
catalog : `~astropy.table.Table`
Astropy Table with 'source_sum' column for the measured flux for each source.
photmode : str
Specification of the observation filter configuration used for... | [
"Compute",
"magnitudes",
"for",
"sources",
"from",
"catalog",
"based",
"on",
"observations",
"photmode",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/hlautils/astrometric_utils.py#L726-L758 |
spacetelescope/drizzlepac | drizzlepac/hlautils/astrometric_utils.py | filter_catalog | def filter_catalog(catalog, **kwargs):
""" Create a new catalog selected from input based on photometry.
Parameters
----------
bright_limit : float
Fraction of catalog based on brightness that should be retained.
Value of 1.00 means full catalog.
max_bright : int
Maximum nu... | python | def filter_catalog(catalog, **kwargs):
""" Create a new catalog selected from input based on photometry.
Parameters
----------
bright_limit : float
Fraction of catalog based on brightness that should be retained.
Value of 1.00 means full catalog.
max_bright : int
Maximum nu... | [
"def",
"filter_catalog",
"(",
"catalog",
",",
"*",
"*",
"kwargs",
")",
":",
"# interpret input pars",
"bright_limit",
"=",
"kwargs",
".",
"get",
"(",
"'bright_limit'",
",",
"1.00",
")",
"max_bright",
"=",
"kwargs",
".",
"get",
"(",
"'max_bright'",
",",
"None... | Create a new catalog selected from input based on photometry.
Parameters
----------
bright_limit : float
Fraction of catalog based on brightness that should be retained.
Value of 1.00 means full catalog.
max_bright : int
Maximum number of sources to keep regardless of `bright_l... | [
"Create",
"a",
"new",
"catalog",
"selected",
"from",
"input",
"based",
"on",
"photometry",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/hlautils/astrometric_utils.py#L761-L804 |
spacetelescope/drizzlepac | drizzlepac/hlautils/astrometric_utils.py | build_self_reference | def build_self_reference(filename, clean_wcs=False):
""" This function creates a reference, undistorted WCS that can be used to
apply a correction to the WCS of the input file.
Parameters
----------
filename : str
Filename of image which will be corrected, and which will form the basis
... | python | def build_self_reference(filename, clean_wcs=False):
""" This function creates a reference, undistorted WCS that can be used to
apply a correction to the WCS of the input file.
Parameters
----------
filename : str
Filename of image which will be corrected, and which will form the basis
... | [
"def",
"build_self_reference",
"(",
"filename",
",",
"clean_wcs",
"=",
"False",
")",
":",
"if",
"'sipwcs'",
"in",
"filename",
":",
"sciname",
"=",
"'sipwcs'",
"else",
":",
"sciname",
"=",
"'sci'",
"wcslin",
"=",
"build_reference_wcs",
"(",
"[",
"filename",
"... | This function creates a reference, undistorted WCS that can be used to
apply a correction to the WCS of the input file.
Parameters
----------
filename : str
Filename of image which will be corrected, and which will form the basis
of the undistorted WCS.
clean_wcs : bool
Spe... | [
"This",
"function",
"creates",
"a",
"reference",
"undistorted",
"WCS",
"that",
"can",
"be",
"used",
"to",
"apply",
"a",
"correction",
"to",
"the",
"WCS",
"of",
"the",
"input",
"file",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/hlautils/astrometric_utils.py#L807-L855 |
spacetelescope/drizzlepac | drizzlepac/hlautils/astrometric_utils.py | read_hlet_wcs | def read_hlet_wcs(filename, ext):
"""Insure `stwcs.wcsutil.HSTWCS` includes all attributes of a full image WCS.
For headerlets, the WCS does not contain information about the size of the
image, as the image array is not present in the headerlet.
"""
hstwcs = wcsutil.HSTWCS(filename, ext=ext)
if... | python | def read_hlet_wcs(filename, ext):
"""Insure `stwcs.wcsutil.HSTWCS` includes all attributes of a full image WCS.
For headerlets, the WCS does not contain information about the size of the
image, as the image array is not present in the headerlet.
"""
hstwcs = wcsutil.HSTWCS(filename, ext=ext)
if... | [
"def",
"read_hlet_wcs",
"(",
"filename",
",",
"ext",
")",
":",
"hstwcs",
"=",
"wcsutil",
".",
"HSTWCS",
"(",
"filename",
",",
"ext",
"=",
"ext",
")",
"if",
"hstwcs",
".",
"naxis1",
"is",
"None",
":",
"hstwcs",
".",
"naxis1",
"=",
"int",
"(",
"hstwcs"... | Insure `stwcs.wcsutil.HSTWCS` includes all attributes of a full image WCS.
For headerlets, the WCS does not contain information about the size of the
image, as the image array is not present in the headerlet. | [
"Insure",
"stwcs",
".",
"wcsutil",
".",
"HSTWCS",
"includes",
"all",
"attributes",
"of",
"a",
"full",
"image",
"WCS",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/hlautils/astrometric_utils.py#L858-L869 |
spacetelescope/drizzlepac | drizzlepac/hlautils/astrometric_utils.py | build_hstwcs | def build_hstwcs(crval1, crval2, crpix1, crpix2, naxis1, naxis2, pscale, orientat):
""" Create an `stwcs.wcsutil.HSTWCS` object for a default instrument without
distortion based on user provided parameter values.
"""
wcsout = wcsutil.HSTWCS()
wcsout.wcs.crval = np.array([crval1, crval2])
wcsout.... | python | def build_hstwcs(crval1, crval2, crpix1, crpix2, naxis1, naxis2, pscale, orientat):
""" Create an `stwcs.wcsutil.HSTWCS` object for a default instrument without
distortion based on user provided parameter values.
"""
wcsout = wcsutil.HSTWCS()
wcsout.wcs.crval = np.array([crval1, crval2])
wcsout.... | [
"def",
"build_hstwcs",
"(",
"crval1",
",",
"crval2",
",",
"crpix1",
",",
"crpix2",
",",
"naxis1",
",",
"naxis2",
",",
"pscale",
",",
"orientat",
")",
":",
"wcsout",
"=",
"wcsutil",
".",
"HSTWCS",
"(",
")",
"wcsout",
".",
"wcs",
".",
"crval",
"=",
"np... | Create an `stwcs.wcsutil.HSTWCS` object for a default instrument without
distortion based on user provided parameter values. | [
"Create",
"an",
"stwcs",
".",
"wcsutil",
".",
"HSTWCS",
"object",
"for",
"a",
"default",
"instrument",
"without",
"distortion",
"based",
"on",
"user",
"provided",
"parameter",
"values",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/hlautils/astrometric_utils.py#L872-L888 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.