Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.extension
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.extension
Commits
a44b314c
Commit
a44b314c
authored
10 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
Implement requirements.txt file loading
parent
0b8cfa8a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bob/extension/test_utils.py
+19
-1
19 additions, 1 deletion
bob/extension/test_utils.py
bob/extension/utils.py
+10
-0
10 additions, 0 deletions
bob/extension/utils.py
with
29 additions
and
1 deletion
bob/extension/test_utils.py
+
19
−
1
View file @
a44b314c
...
...
@@ -9,7 +9,8 @@
import
os
import
sys
import
nose.tools
from
.utils
import
uniq
,
egrep
,
find_file
,
find_header
,
find_library
from
.utils
import
uniq
,
egrep
,
find_file
,
find_header
,
find_library
,
\
load_requirements
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-b
package-c
#package-e #not to be included
package-z
"""
result
=
load_requirements
(
stringio
(
f
))
expected
=
[
'
package-a >= 0.42
'
,
'
package-b
'
,
'
package-c
'
,
'
package-z
'
]
nose
.
tools
.
eq_
(
result
,
expected
)
This diff is collapsed.
Click to expand it.
bob/extension/utils.py
+
10
−
0
View file @
a44b314c
...
...
@@ -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
]
!=
'
#
'
]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment