Skip to content

Commit

Permalink
add requirements.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdecker1201 committed Feb 10, 2023
1 parent 4878eba commit 415c3b0
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CONTRIBUTING.md
Expand Up @@ -26,9 +26,12 @@ Here's the process to make changes to the codebase:
2. Review [open pull requests](https://github.com/spdx/tools-python/pulls) before committing time to a substantial
revision. Work along similar lines may already be in progress.

3. Create a new branch:
3. Create a new branch and set up environment:
```sh
git checkout -b fix-or-improve-something
python -m venv ./venv
./venv/bin/activate
pip install -r requirements.txt
```
4. Make some changes and commit them to the branch:
```sh
Expand Down
7 changes: 7 additions & 0 deletions requirements.txt
@@ -0,0 +1,7 @@
click
ply
pytest
pyyaml
rdflib
uritools
xmltodict
7 changes: 5 additions & 2 deletions spdx/parsers/parse_anything.py
Expand Up @@ -21,10 +21,13 @@
from spdx.parsers.builderexceptions import FileTypeError


def parse_file(fn):
def parse_file(fn, encoding="utf-8"):
in_mode = "r"
builder_module = jsonyamlxmlbuilders
read_data = False
if fn.endswith(".rdf") or fn.endswith(".rdf.xml"):
in_mode = "rb"
encoding = None
parsing_module = rdf
builder_module = rdfbuilders
elif fn.endswith(".tag") or fn.endswith(".spdx"):
Expand All @@ -43,7 +46,7 @@ def parse_file(fn):
p = parsing_module.Parser(builder_module.Builder(), StandardLogger())
if hasattr(p, "build"):
p.build()
with open(fn) as f:
with open(fn, in_mode, encoding=encoding) as f:
if read_data:
data = f.read()
return p.parse(data)
Expand Down
1 change: 1 addition & 0 deletions spdx/writers/write_anything.py
Expand Up @@ -23,6 +23,7 @@ def write_file(doc, fn, validate=True, encoding="utf-8"):
if fn.endswith(".rdf") or fn.endswith(".rdf.xml"):
writer_module = rdf
out_mode = "wb"
encoding = None
elif fn.endswith(".tag") or fn.endswith(".spdx"):
writer_module = tagvalue
elif fn.endswith(".json"):
Expand Down

0 comments on commit 415c3b0

Please sign in to comment.