Commit a44b314c authored by André Anjos's avatar André Anjos 💬
Browse files

Implement requirements.txt file loading

parent 0b8cfa8a
......@@ -9,7 +9,8 @@
import os
import sys
from .utils import uniq, egrep, find_file, find_header, find_library
from .utils import uniq, egrep, find_file, find_header, find_library, \
def test_uniq():
......@@ -87,3 +88,20 @@ def test_find_versioned_library():
for k in lib:
assert k.find('boost_system') >= 0
def test_requirement_readout():
from StringIO import StringIO as stringio
f = """ # this is my requirements file
package-a >= 0.42
#package-e #not to be included
result = load_requirements(stringio(f))
expected = ['package-a >= 0.42', 'package-b', 'package-c', 'package-z'], expected)
......@@ -325,3 +325,13 @@ def egrep(filename, expression):
if p: retval.append(p)
return retval
def load_requirements(f=None):
"""Loads the contents of requirements.txt on the given path.
Defaults to "./requirements.txt"
f = f if f is not None else open("requirements.txt", 'rt')
retval = [k.strip() for k in f]
return [k for k in retval if k and k[0] != '#']
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment