add File.project_path property

Provide a quick way to get a short but unique name to a file.
This commit is contained in:
Doug Hellmann 2014-11-06 15:45:36 +01:00
parent 8c41c9516a
commit 2e4c6cb74a
2 changed files with 6 additions and 1 deletions

View File

@ -25,6 +25,10 @@ class File(Base):
backref='file',
cascade="all, delete, delete-orphan")
@property
def project_path(self):
return '%s/%s' % (self.project.name, self.name)
class Line(Base):
__tablename__ = 'line'

View File

@ -13,13 +13,14 @@ class RequirementsHandler(base.FileHandler):
INTERESTING_PATTERNS = ['*requirements*.txt']
def process_file(self, session, file_obj):
LOG.info('loading requirements from %s', file_obj.path)
LOG.info('loading requirements from %s', file_obj.project_path)
parent_project = file_obj.project
for line in file_obj.lines:
text = line.content.strip()
if not text or text.startswith('#'):
continue
try:
# FIXME(dhellmann): Use pbr's requirements parser.
dist_name = pkg_resources.Requirement.parse(text).project_name
except ValueError:
LOG.warn('could not parse dist name from %r',