Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ target/
# pyenv python configuration file
.python-version
sandbox.py
/tmp/
20 changes: 20 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@
History
=======

0.4.1 (2018-04-06)
------------------

* Fixed a packaging error.

0.4.0 (2018-04-06)
------------------

* pipenv is now an optional dependency that's only used when updating a Pipfile. Install it with dparse[pipenv]
* Added support for invalid toml Pipfiles (thanks @pombredanne)


0.3.0 (2018-03-01)
------------------

* Added support for setup.cfg files (thanks @kexepal)
* Dependencies from Pipfiles now include the section (thanks @paulortman)
* Multiline requirements are now ignored if they are marked
* Added experimental support for Pipfiles

0.2.1 (2017-07-19)
------------------

Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ recursive-exclude * __pycache__
recursive-exclude * *.py[co]

recursive-include docs *.rst conf.py Makefile make.bat *.jpg *.png *.gif
recursive-include dparse *.py
8 changes: 7 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Supported Files
+------------------+------------+-----------+
| setup.py | no (# 2_) | no (# 2_) |
+------------------+------------+-----------+
| zc.buildout | no (# 3_) | no (# 3_) |
| zc.buildout | no (# 3_) | no (# 3_) |
+------------------+------------+-----------+
| setup.cfg | no (# 4_) | no (# 4_) |
+------------------+------------+-----------+
Expand All @@ -65,6 +65,12 @@ To install dparse, run:

$ pip install dparse

If you want to update Pipfiles, install the pipenv extra:

.. code-block:: console

$ pip install dparse[pipenv]

*****
Usage
*****
Expand Down
4 changes: 2 additions & 2 deletions dparse/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""Top-level package for Dependency Parser."""

__author__ = """Jannis Gebauer"""
__email__ = 'ja.geb@me.com'
__version__ = '0.2.1'
__email__ = 'jay@pyup.io'
__version__ = '0.4.1'

from .parser import parse
12 changes: 6 additions & 6 deletions dparse/parser.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
from collections import OrderedDict
import re
import yaml

Expand Down Expand Up @@ -27,7 +28,7 @@
from packaging.requirements import Requirement as PackagingRequirement, InvalidRequirement
import six
from . import filetypes
from pipenv.vendor import toml
from .vendor import toml
from packaging.specifiers import SpecifierSet
import json

Expand Down Expand Up @@ -338,7 +339,7 @@ def parse(self):
:return:
"""
try:
data = toml.loads(self.obj.content)
data = toml.loads(self.obj.content, _dict=OrderedDict)
if data:
for package_type in ['packages', 'dev-packages']:
if package_type in data:
Expand All @@ -356,10 +357,9 @@ def parse(self):
section=package_type
)
)
except toml.TomlDecodeError:
except (toml.TomlDecodeError, IndexError) as e:
pass


class PipfileLockParser(Parser):

def parse(self):
Expand All @@ -368,7 +368,7 @@ def parse(self):
:return:
"""
try:
data = json.loads(self.obj.content)
data = json.loads(self.obj.content, object_pairs_hook=OrderedDict)
if data:
for package_type in ['default', 'develop']:
if package_type in data:
Expand All @@ -387,7 +387,7 @@ def parse(self):
section=package_type
)
)
except json.JSONDecodeError:
except ValueError:
pass


Expand Down
8 changes: 6 additions & 2 deletions dparse/updater.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
# Python 2 & 3 compatible StringIO
import tempfile
import toml
from .vendor import toml
import os


Expand Down Expand Up @@ -85,7 +85,11 @@ def update(cls, content, dependency, version, spec="==", hashes=()):
data[package_type][dependency.full_name] = "{spec}{version}".format(
spec=spec, version=version
)
from pipenv.project import Project
try:
from pipenv.project import Project
except ImportError:
raise ImportError("Updating a Pipfile requires the pipenv extra to be installed. Install it with "
"pip install dparse[pipenv]")
pipfile = tempfile.NamedTemporaryFile(delete=False)
p = Project(chdir=False)
p.write_toml(data=data, path=pipfile.name)
Expand Down
Empty file added dparse/vendor/__init__.py
Empty file.
Loading