Skip to content

Commit 78edfc1

Browse files
committed
enh: updated from upstream
1 parent 21632a7 commit 78edfc1

File tree

1 file changed

+8
-28
lines changed

1 file changed

+8
-28
lines changed

nipype/external/provcopy.py

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import datetime
1515
import json
1616
import re
17+
import dateutil.parser
1718
import collections
1819
from collections import defaultdict
1920

@@ -179,31 +180,10 @@
179180

180181

181182
# Datatypes
182-
_r_xsd_dateTime = re.compile(""" ^
183-
(?P<year>-?[0-9]{4}) - (?P<month>[0-9]{2}) - (?P<day>[0-9]{2})
184-
T (?P<hour>[0-9]{2}) : (?P<minute>[0-9]{2}) : (?P<second>[0-9]{2})
185-
(?P<microsecond>\.[0-9]{1,6})?
186-
(?P<tz>
187-
Z | (?P<tz_hr>[-+][0-9]{2}) : (?P<tz_min>[0-9]{2})
188-
)?
189-
$ """, re.X)
190-
191183
attr2rdf = lambda attr: PROV[PROV_ID_ATTRIBUTES_MAP[attr].split('prov:')[1]].rdf_representation()
192184

193185
def _parse_xsd_dateTime(s):
194-
"""Returns datetime or None."""
195-
m = _r_xsd_dateTime.match(s)
196-
if m is not None:
197-
values = m.groupdict()
198-
if values["microsecond"] is None:
199-
values["microsecond"] = 0
200-
else:
201-
values["microsecond"] = values["microsecond"][1:]
202-
values["microsecond"] += "0" * (6 - len(values["microsecond"]))
203-
values = dict((k, int(v)) for k, v in values.iteritems() if not k.startswith("tz"))
204-
return datetime.datetime(**values)
205-
else:
206-
return None
186+
return dateutil.parser.parse(s)
207187

208188

209189
def _ensure_datetime(time):
@@ -359,7 +339,7 @@ def provn_representation(self):
359339

360340
def json_representation(self):
361341
return {'$': self._uri, 'type': u'xsd:anyURI'}
362-
342+
363343
def rdf_representation(self):
364344
return URIRef(self.get_uri())
365345

@@ -773,7 +753,7 @@ def rdf(self, graph=None, subj=None):
773753
obj = RDFLiteral(value)
774754
graph.add((subj, pred, obj))
775755
return graph
776-
756+
777757
def is_asserted(self):
778758
return self._asserted
779759

@@ -788,7 +768,7 @@ def is_relation(self):
788768
class ProvElement(ProvRecord):
789769
def is_element(self):
790770
return True
791-
771+
792772
def rdf(self, graph=None):
793773
if graph is None:
794774
graph = Graph()
@@ -1666,15 +1646,15 @@ def rdf(self, graph=None):
16661646
# graph should not None here
16671647
uri = self.get_identifier().rdf_representation()
16681648
graph = Graph(graph.store, uri)
1669-
1649+
16701650
for prefix, namespace in self._namespaces.items():
16711651
graph.bind(prefix, namespace.get_uri())
1672-
1652+
16731653
for record in self._records:
16741654
if record.is_asserted():
16751655
record.rdf(graph)
16761656
return graph
1677-
1657+
16781658
def get_provjson(self, **kw):
16791659
"""Return the `PROV-JSON <http://www.w3.org/Submission/prov-json/>`_ representation for the bundle/document.
16801660

0 commit comments

Comments
 (0)