Skip to content

Commit

Permalink
pass allow_unsafe to write for unsafe dep comment output
Browse files Browse the repository at this point in the history
  • Loading branch information
Derek Schaller committed May 28, 2017
1 parent 549edc0 commit 066f0ea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion piptools/scripts/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,8 @@ def cli(verbose, dry_run, pre, rebuild, find_links, index_url, extra_index_url,
primary_packages={key_from_req(ireq.req) for ireq in constraints if not ireq.constraint},
markers={key_from_req(ireq.req): ireq.markers
for ireq in constraints if ireq.markers},
hashes=hashes)
hashes=hashes,
allow_unsafe=allow_unsafe)

if dry_run:
log.warning('Dry-run, so nothing updated.')
Expand Down
13 changes: 9 additions & 4 deletions piptools/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def write_flags(self):
if emitted:
yield ''

def _iter_lines(self, results, unsafe_requirements, reverse_dependencies, primary_packages, markers, hashes):
def _iter_lines(self, results, unsafe_requirements, reverse_dependencies,
primary_packages, markers, hashes, allow_unsafe=False):
for line in self.write_header():
yield line
for line in self.write_flags():
Expand Down Expand Up @@ -109,16 +110,20 @@ def _iter_lines(self, results, unsafe_requirements, reverse_dependencies, primar
primary_packages,
marker=markers.get(ireq.req.name),
hashes=hashes)
yield comment('# {}'.format(req))
if not allow_unsafe:
yield comment('# {}'.format(req))
else:
yield req

def write(self, results, unsafe_requirements, reverse_dependencies, primary_packages, markers, hashes):
def write(self, results, unsafe_requirements, reverse_dependencies,
primary_packages, markers, hashes, allow_unsafe=False):
with ExitStack() as stack:
f = None
if not self.dry_run:
f = stack.enter_context(AtomicSaver(self.dst_file))

for line in self._iter_lines(results, unsafe_requirements, reverse_dependencies,
primary_packages, markers, hashes):
primary_packages, markers, hashes, allow_unsafe=allow_unsafe):
log.info(line)
if f:
f.write(unstyle(line).encode('utf-8'))
Expand Down

0 comments on commit 066f0ea

Please sign in to comment.