Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Test existing file unknown key
temp_path, fpaths = _create_test_files((
('', 'PKG-INFO', 'Unknown-Key: unknown\n'),
))
output = func(fpaths[0])
expected_output = odict()
_print_output(output, expected_output)
assert output == expected_output
# Test existing file known key
temp_path, fpaths = _create_test_files((
('', 'PKG-INFO', 'Name: spam\n'),
))
output = func(fpaths[0])
expected_output = odict(name='spam')
_print_output(output, expected_output)
assert output == expected_output
# Test non existing file
test_fpath = '/foo/bar/METADATA'
output = func(test_fpath)
expected_output = odict()
_print_output(output, expected_output)
assert output == expected_output
def test_Solver_inputs_contract():
init_args = odict((
('self', PositionalArgument),
('prefix', PositionalArgument),
('channels', PositionalArgument),
('subdirs', ()),
('specs_to_add', ()),
('specs_to_remove', ()),
))
inspect_arguments(Solver.__init__, init_args)
solve_final_state_args = odict((
('self', PositionalArgument),
('deps_modifier', NULL),
('prune', NULL),
('ignore_pinned', NULL),
('force_remove', NULL),
))
def test_PrefixData_contract():
init_args = odict((
('self', PositionalArgument),
('prefix_path', PositionalArgument),
))
inspect_arguments(PrefixData.__init__, init_args)
get_args = odict((
('self', PositionalArgument),
('package_ref', PositionalArgument),
('default', NULL),
))
inspect_arguments(PrefixData.get, get_args)
query_args = odict((
('self', PositionalArgument),
('package_ref_or_match_spec', PositionalArgument),
))
inspect_arguments(PrefixData.query, query_args)
iter_records_args = odict((
('self', PositionalArgument),
))
inspect_arguments(PrefixData.iter_records, iter_records_args)
def load_from_string_data(*seq):
return odict((f, YamlRawParameter.make_raw_parameters(f, yaml_load(test_yaml_raw[f])))
for f in seq)
chuck: http://user1:pass2@another.url:8080/t/tk-1234/with/path
pkgs/anaconda: http://192.168.0.15:8080
migrated_custom_channels:
darwin: s3://just/cant
chuck: file:///var/lib/repo/
pkgs/anaconda: https://repo.anaconda.com
migrated_channel_aliases:
- https://conda.anaconda.org
channel_alias: ftp://new.url:8082
default_channels:
- http://192.168.0.15:8080/pkgs/anaconda
- http://192.168.0.15:8080/pkgs/pro
- http://192.168.0.15:8080/pkgs/msys2
""")
reset_context()
rd = odict(testdata=YamlRawParameter.make_raw_parameters('testdata', yaml_load(string)))
context._set_raw_data(rd)
Channel._reset_state()
cls.platform = context.subdir
cls.DEFAULT_URLS = ['http://192.168.0.15:8080/pkgs/anaconda/%s' % cls.platform,
'http://192.168.0.15:8080/pkgs/anaconda/noarch',
'http://192.168.0.15:8080/pkgs/pro/%s' % cls.platform,
'http://192.168.0.15:8080/pkgs/pro/noarch',
'http://192.168.0.15:8080/pkgs/msys2/%s' % cls.platform,
'http://192.168.0.15:8080/pkgs/msys2/noarch',
]
def test_get_entry_points():
test_files = (
('', 'METADATA', 'Name: spam\n'),
('', 'entry_points.txt', '[console_scripts]\ncheese = cli:main\n'),
)
temp_path, fpaths = _create_test_files(test_files)
dist = PythonEggInfoDistribution(temp_path, "2.7", None)
output = dist.get_entry_points()
expected_output = odict(console_scripts=odict(cheese='cli:main'))
_print_output(output, expected_output)
assert output == expected_output
def _parse_entries_file_data(data):
"""
https://setuptools.readthedocs.io/en/latest/formats.html#entry-points-txt-entry-point-plugin-metadata
"""
# FIXME: Use pkg_resources which provides API for this?
entries_data = odict()
config = ConfigParser()
config.optionxform = lambda x: x # Avoid lowercasing keys
config.readfp(StringIO(data))
for section in config.sections():
entries_data[section] = odict(config.items(section))
return entries_data
def _toposort(self):
graph_copy = odict((node, IndexedSet(parents)) for node, parents in iteritems(self.graph))
self._toposort_prepare_graph(graph_copy)
if context.allow_cycles:
sorted_nodes = tuple(self._topo_sort_handle_cycles(graph_copy))
else:
sorted_nodes = tuple(self._toposort_raise_on_cycles(graph_copy))
original_graph = self.graph
self.graph = odict((node, original_graph[node]) for node in sorted_nodes)
return sorted_nodes
def _read_metadata(cls, fpath):
"""
Read the original format which is stored as RFC-822 headers.
"""
data = odict()
if fpath and isfile(fpath):
parser = HeaderParser()
# FIXME: Is this a correct assumption for the encoding?
# This was needed due to some errors on windows
with open(fpath) as fp:
data = parser.parse(fp)
return cls._message_to_dict(data)