Skip to content

Commit

Permalink
Revert "Update to 0.11.1 EditorConfig Python Core library"
Browse files Browse the repository at this point in the history
This reverts commit 35c063e.
  • Loading branch information
xuhdev committed Nov 9, 2018
1 parent 53d469c commit 5e1121e
Showing 33 changed files with 666 additions and 905 deletions.
12 changes: 8 additions & 4 deletions editorconfig-core-py/.editorconfig
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
root = true

[*.{py,rst,txt}]
[*.py]
indent_style = space
trim_trailing_whitespace = true
indent_size = 4
end_of_line = LF

[*.yml]
[*.rst]
indent_style = space
indent_size = 2
indent_size = 4
end_of_line = LF

[*.txt]
indent_style = space
indent_size = 4
end_of_line = LF
43 changes: 12 additions & 31 deletions editorconfig-core-py/.travis.yml
Original file line number Diff line number Diff line change
@@ -6,46 +6,27 @@ python:
- "2.5"
- "2.6"
- "2.7"
- "3.2"
- "3.3"
- "jython"

# For testing with JYTHON=true, we will use Jython 2.2 instead of the python
# version provided by Travis CI
env:
- JYTHON=true
- JYTHON=false

matrix:
exclude:
- python: "2.5"
env: JYTHON=true
- python: "2.6"
env: JYTHON=true
- python: "3.2"
env: JYTHON=true
- python: "3.3"
env: JYTHON=true

# we need cmake, and jython if JYTHON=true
# we need cmake, and jython if the python version is "jython"
install:
- sudo apt-get install cmake ant
- sudo apt-get install cmake
- export JYTHON_URL='http://downloads.sourceforge.net/project/jython/jython/2.2.1/jython_installer-2.2.1.jar?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fjython%2Ffiles%2Fjython%2F2.2.1%2F&ts=1338180153&use_mirror=iweb'
- if [ "$JYTHON" == "true" ]; then wget $JYTHON_URL -O jython_installer.jar; java -jar jython_installer.jar -s -d $HOME/jython; export PATH=$HOME/jython:$PATH;jython --version; fi
- if [ "$TRAVIS_PYTHON_VERSION" == "jython" ]; then wget $JYTHON_URL -O jython_installer.jar; java -jar jython_installer.jar -s -d $HOME/jython; export PATH=$HOME/jython:$PATH;jython --version; fi

# Before run the test case, we need to make jython run some code
# Before run the test case, we need to make jython run some other code
before_script:
- if [ "$JYTHON" == "true" ]; then jython -c "print ''"; fi
- if [ "$TRAVIS_PYTHON_VERSION" == "jython" ]; then jython -c "print ''"; fi

# test script
script:
- if [ "$JYTHON" == "true" ]; then cmake -DPYTHON_EXECUTABLE="$(which jython)" . ; else cmake . ; fi
- if [ "$TRAVIS_PYTHON_VERSION" == "jython" ]; then cmake -DPYTHON_EXECUTABLE="$(which jython)" . ; else cmake . ; fi
- ctest -V --output-on-failure .
- cd java-binding
- ant -v
- ant -v doc

# Notify the mailing list
notifications:
email:
on_success: change
on_failure: always
recipients:
- editorconfig@googlegroups.com
email:
on_success: change
on_failure: always
1 change: 0 additions & 1 deletion editorconfig-core-py/MANIFEST.in

This file was deleted.

13 changes: 1 addition & 12 deletions editorconfig-core-py/README.rst
Original file line number Diff line number Diff line change
@@ -40,9 +40,7 @@ may want to import and use the EditorConfig Python Core directly.
Using as a Library
==================

Basic example use of EditorConfig Python Core as a library:

.. code-block:: python
Basic example use of EditorConfig Python Core as a library::

from editorconfig import get_properties, EditorConfigError

@@ -56,9 +54,6 @@ Basic example use of EditorConfig Python Core as a library:
for key, value in options.items():
print "%s=%s" % (key, value)

For details, please take a look at the `online documentation
<http://pydocs.editorconfig.org>`_.

Running Test Cases
==================

@@ -68,12 +63,6 @@ using the following commands::
cmake .
ctest .

Use ``-DPYTHON_EXECUTABLE`` to run the tests using an alternative versions of
Python (Python 3, Jython, etc.)::

cmake -DPYTHON_EXECUTABLE=/usr/bin/python3 .
ctest .

License
=======

9 changes: 3 additions & 6 deletions editorconfig-core-py/docs/conf.py
Original file line number Diff line number Diff line change
@@ -16,10 +16,7 @@
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath('..'))

import editorconfig
from editorconfig import __version__
#sys.path.insert(0, os.path.abspath('.'))

# -- General configuration -----------------------------------------------------

@@ -51,9 +48,9 @@
# built documents.
#
# The short X.Y version.
version = __version__
version = '0.9.0'
# The full version, including alpha/beta/rc tags.
release = __version__
release = '0.9.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
72 changes: 0 additions & 72 deletions editorconfig-core-py/docs/plugins.rst

This file was deleted.

8 changes: 2 additions & 6 deletions editorconfig-core-py/docs/usage.rst
Original file line number Diff line number Diff line change
@@ -15,9 +15,7 @@ Discovering EditorConfig properties
-----------------------------------

The ``get_properties`` function can be used to discover EditorConfig properties
for a given file. Example:

.. code-block:: python
for a given file. Example::

import logging
from editorconfig import get_properties, EditorConfigError
@@ -61,9 +59,7 @@ the current exception types:
Exception handling example
~~~~~~~~~~~~~~~~~~~~~~~~~~

An example of custom exception handling:

.. code-block:: python
An example of custom exception handling::

import logging
from editorconfig import get_properties
8 changes: 4 additions & 4 deletions editorconfig-core-py/editorconfig/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""EditorConfig Python Core"""

from editorconfig.versiontools import join_version
from versiontools import join_version

VERSION = (0, 11, 1, "final")
VERSION = (0, 9, 0, "final")

__all__ = ['get_properties', 'EditorConfigError', 'exceptions']

@@ -15,5 +15,5 @@ def get_properties(filename):
return handler.get_configurations()


from editorconfig.handler import EditorConfigHandler
from editorconfig.exceptions import *
from handler import EditorConfigHandler
from exceptions import *
18 changes: 0 additions & 18 deletions editorconfig-core-py/editorconfig/compat.py

This file was deleted.

5 changes: 1 addition & 4 deletions editorconfig-core-py/editorconfig/exceptions.py
Original file line number Diff line number Diff line change
@@ -9,10 +9,7 @@ class EditorConfigError(Exception):
"""Parent class of all exceptions raised by EditorConfig"""


try:
from ConfigParser import ParsingError as _ParsingError
except:
from configparser import ParsingError as _ParsingError
from ConfigParser import ParsingError as _ParsingError


class ParsingError(_ParsingError, EditorConfigError):
52 changes: 12 additions & 40 deletions editorconfig-core-py/editorconfig/fnmatch.py
Original file line number Diff line number Diff line change
@@ -24,18 +24,16 @@

_cache = {}


def fnmatch(name, pat):
"""Test whether FILENAME matches PATTERN.
Patterns are Unix shell style:
- ``*`` matches everything except path separator
- ``**`` matches everything
- ``?`` matches any single character
- ``[seq]`` matches any character in seq
- ``[!seq]`` matches any char not in seq
- ``{s1,s2,s3}`` matches any of the strings given (separated by commas)
- ``*`` matches everything except path separator
- ``**`` matches everything
- ``?`` matches any single character
- ``[seq]`` matches any character in seq
- ``[!seq]`` matches any char not in seq
An initial period in FILENAME is not special.
Both FILENAME and PATTERN are first case-normalized
@@ -46,7 +44,6 @@ def fnmatch(name, pat):
name = os.path.normcase(name).replace(os.sep, "/")
return fnmatchcase(name, pat)


def fnmatchcase(name, pat):
"""Test whether FILENAME matches PATTERN, including case.
@@ -59,7 +56,6 @@ def fnmatchcase(name, pat):
_cache[pat] = re.compile(res)
return _cache[pat].match(name) is not None


def translate(pat):
"""Translate a shell PATTERN to a regular expression.
@@ -68,10 +64,9 @@ def translate(pat):

i, n = 0, len(pat)
res = ''
escaped = False
while i < n:
c = pat[i]
i = i + 1
i = i+1
if c == '*':
j = i
if j < n and pat[j] == '*':
@@ -83,44 +78,21 @@ def translate(pat):
elif c == '[':
j = i
if j < n and pat[j] == '!':
j = j + 1
j = j+1
if j < n and pat[j] == ']':
j = j + 1
while j < n and (pat[j] != ']' or escaped):
escaped = pat[j] == '\\' and not escaped
j = j + 1
j = j+1
while j < n and pat[j] != ']':
j = j+1
if j >= n:
res = res + '\\['
else:
stuff = pat[i:j]
i = j + 1
stuff = pat[i:j].replace('\\','\\\\')
i = j+1
if stuff[0] == '!':
stuff = '^' + stuff[1:]
elif stuff[0] == '^':
stuff = '\\' + stuff
res = '%s[%s]' % (res, stuff)
elif c == '{':
j = i
groups = []
while j < n and pat[j] != '}':
k = j
while k < n and (pat[k] not in (',', '}') or escaped):
escaped = pat[k] == '\\' and not escaped
k = k + 1
group = pat[j:k]
for char in (',', '}', '\\'):
group = group.replace('\\' + char, char)
groups.append(group)
j = k
if j < n and pat[j] == ',':
j = j + 1
if j < n and pat[j] == '}':
groups.append('')
if j >= n or len(groups) < 2:
res = res + '\\{'
else:
res = '%s(%s)' % (res, '|'.join(map(re.escape, groups)))
i = j + 1
else:
res = res + re.escape(c)
return res + '\Z(?ms)'
Loading

0 comments on commit 5e1121e

Please sign in to comment.