Revert "Fix formatting and remove unused code"

This reverts commit d7898d586f.
This commit is contained in:
ines 2017-03-16 09:58:41 +01:00
parent 2f0db1dd36
commit 7b2eca36e4
1 changed files with 15 additions and 1 deletions

View File

@ -6,12 +6,12 @@ import json
import re
import os.path
import pathlib
import six
import textwrap
from .attrs import TAG, HEAD, DEP, ENT_IOB, ENT_TYPE
try:
basestring
except NameError:
@ -76,6 +76,20 @@ def split_data_name(name):
return name.split('-', 1) if '-' in name else (name, '')
def constraint_match(constraint_string, version):
# From http://github.com/spacy-io/sputnik
if not constraint_string:
return True
constraints = [c.strip() for c in constraint_string.split(',') if c.strip()]
for c in constraints:
if not re.match(r'[><=][=]?\d+(\.\d+)*', c):
raise ValueError('invalid constraint: %s' % c)
return all(semver.match(version, c) for c in constraints)
def read_regex(path):
path = path if not isinstance(path, basestring) else pathlib.Path(path)
with path.open() as file_: