From 729365ff99258099f1112251604150515e4f132b Mon Sep 17 00:00:00 2001 From: Hans-Dieter Stich Date: Fri, 24 Feb 2017 13:05:49 +0100 Subject: [PATCH 1/9] Added PR 'Py3K fix for -i option' PR: https://github.com/portante/pycscope/pull/26 --- .gitignore | 1 + pycscope/__init__.py | 23 ++++++++++------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 46aec8a..c87703c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ pycscope.files pycscope.out dist pycscope.egg-info +.ropeproject/ diff --git a/pycscope/__init__.py b/pycscope/__init__.py index e0adc90..39835c8 100755 --- a/pycscope/__init__.py +++ b/pycscope/__init__.py @@ -20,8 +20,9 @@ -f reffile Use 'reffile' as cross-ref file name instead of 'cscope.out' -i srclistfile Use the contents of 'srclistfile' as the list of source files to scan""" -import getopt, sys, os, string, re +import getopt, sys, os, re import keyword, parser, symbol, token +import tokenize class Mark(object): @@ -117,7 +118,8 @@ def main(argv=None): if o == "-f": indexfn = a if o == "-i": - args.extend(list(map(string.rstrip, open(a, 'r').readlines()))) + with open(a) as f: + args.extend(x.rstrip() for x in f) # Search current dir by default if len(args) == 0: @@ -148,7 +150,7 @@ def writeIndex(basepath, fout, indexbuff, fnamesbuff): """ # Write the header and index index = ''.join(indexbuff) - index_len = len(index) + index_len = len(index.encode() if isinstance(u'' , str) else index) hdr_len = len(basepath) + 25 fout.write("cscope 15 %s -c %010d" % (basepath, hdr_len + index_len)) fout.write(index) @@ -175,7 +177,8 @@ def work(basepath, gen, debug): indexbuff_len = parseFile(basepath, fname, indexbuff, indexbuff_len, fnamesbuff, dump=debug) except (SyntaxError, AssertionError) as e: print("pycscope.py: %s: Line %s: %s" % (e.filename, e.lineno, e)) - pass + except Exception as e: + print("pycscope.py: %s: %s" % (fname, e)) return indexbuff, fnamesbuff @@ -221,15 +224,9 @@ def parseFile(basepath, relpath, indexbuff, indexbuff_len, fnamesbuff, dump=Fals """ # Open the file and get the contents fullpath = os.path.join(basepath, relpath) - try: - f = open(fullpath, 'rU') - except IOError as e: - # Can't open a file, emit message and ignore - print("pycscope.py: %s" % e) - return indexbuff_len - filecontents = f.read() - f.close() - + bestopen = getattr(tokenize, 'open', open) + with bestopen(fullpath) as f: + filecontents = f.read() # Add the file mark to the index fnamesbuff.append(relpath) indexbuff.append("\n%s%s\n\n" % (Mark(Mark.FILE), relpath)) From 9af6ad2b0c8764f0deba01563c2fd10ad51e1f0f Mon Sep 17 00:00:00 2001 From: lonetwin Date: Wed, 15 Mar 2017 20:21:54 +0100 Subject: [PATCH 2/9] Fix tests --- test/testimports.py | 2 +- test/testissues.py | 2 +- test/testparsefile.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/testimports.py b/test/testimports.py index 8ce7a2d..0a876ba 100644 --- a/test/testimports.py +++ b/test/testimports.py @@ -21,7 +21,7 @@ def setUp(self,): self.maxDiff = None def testimports(self,): - cwd = os.getcwd() + cwd = os.path.dirname(__file__) fn = "imports.py" l = pycscope.parseFile(cwd, fn, self.buf, 0, self.fnbuf) self.assertEqual(l, len(self.buf)) diff --git a/test/testissues.py b/test/testissues.py index ddc0bad..a91343b 100644 --- a/test/testissues.py +++ b/test/testissues.py @@ -18,7 +18,7 @@ def test0018(self,): """ Make sure two newlines occur after a file mark when the source file starts with non-symbol text. """ - cwd = os.getcwd() + cwd = os.path.dirname(__file__) fn = "issue0018.py" l = pycscope.parseFile(cwd, fn, self.buf, 0, self.fnbuf) self.assertEqual(l, len(self.buf)) diff --git a/test/testparsefile.py b/test/testparsefile.py index b3f119e..b368649 100644 --- a/test/testparsefile.py +++ b/test/testparsefile.py @@ -21,13 +21,13 @@ def setUp(self,): self.maxDiff = None def testioerrors(self,): - cwd = os.getcwd() + cwd = os.path.dirname(__file__) fn = "_does_not_exist_.py" - l = pycscope.parseFile(cwd, fn, self.buf, 0, self.fnbuf) - self.assertEqual(l, 0) + with self.assertRaises(IOError): + pycscope.parseFile(cwd, fn, self.buf, 0, self.fnbuf) def testbadsyntax(self,): - cwd = os.getcwd() + cwd = os.path.dirname(__file__) fn = "badsyntax.py" try: l = pycscope.parseFile(cwd, fn, self.buf, 0, self.fnbuf) From 14108aa25452eedd14afe45b0b3eac35aefcb941 Mon Sep 17 00:00:00 2001 From: Jamiel Almeida Date: Sat, 10 Oct 2015 21:29:23 -0700 Subject: [PATCH 3/9] make testgenfiles check for difference in quality not sort stability --- test/testgenfiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/testgenfiles.py b/test/testgenfiles.py index c8a06f9..39861dd 100644 --- a/test/testgenfiles.py +++ b/test/testgenfiles.py @@ -35,6 +35,6 @@ def testgenfiles(self,): # Actual test fs = list(pycscope.genFiles(tmpd, ['a.py', 'b', "s"], True)) - self.assertEquals(fs, ['a.py', 's/t/f.py', 's/t/e.py', 's/d.py', 's/c.py']) + self.assertEquals(sorted(fs), sorted(['a.py', 's/t/f.py', 's/t/e.py', 's/d.py', 's/c.py'])) finally: shutil.rmtree(tmpd) From 5f1920f9e1fd8a64f5d55cce9d93356b8240ec93 Mon Sep 17 00:00:00 2001 From: Jamiel Almeida Date: Sat, 10 Oct 2015 21:29:50 -0700 Subject: [PATCH 4/9] add *.pyc to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c87703c..0bf14a0 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ pycscope.out dist pycscope.egg-info .ropeproject/ +*.pyc From 7236227a399bf247e72f73ce192540aa17d794c4 Mon Sep 17 00:00:00 2001 From: Jamiel Almeida Date: Sat, 10 Oct 2015 21:30:31 -0700 Subject: [PATCH 5/9] add a requirements-test.txt file --- requirements-test.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 requirements-test.txt diff --git a/requirements-test.txt b/requirements-test.txt new file mode 100644 index 0000000..cccbe2f --- /dev/null +++ b/requirements-test.txt @@ -0,0 +1,2 @@ +coverage==4.0 +nose==1.3.7 From f7d16da74f2691b3430c8e24d2d07daf24f5242f Mon Sep 17 00:00:00 2001 From: Peter Portante Date: Sun, 17 Jan 2016 09:25:04 -0500 Subject: [PATCH 6/9] First pass at enabling Travis-CI for >= 2.6 --- .travis.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5fb6213 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,16 @@ +language: python +python: + - "2.6" + - "2.7" + - "pypy" + - "pypy3" + - "3.2" + - "3.3" + - "3.4" + - "3.5" + - "3.5-dev" # 3.5 development branch + - "nightly" # currently points to 3.6-dev +# command to install dependencies +install: "pip install -r requirements-test.txt" +# command to run tests +script: ./runtests From fce18aa7e53ab41264467a3160083b308c87becf Mon Sep 17 00:00:00 2001 From: Peter Portante Date: Thu, 30 Mar 2017 20:34:21 -0400 Subject: [PATCH 7/9] Fix formatting of text in README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index e919a9f..f368469 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +``` ======== PyCscope ======== @@ -192,3 +193,4 @@ Date Release Trac Changes #6 Create project space. ========== ========= ====== ==================================================== +``` From cf317a58318dd6a425247e7f9e3111acf97bbca1 Mon Sep 17 00:00:00 2001 From: Peter Portante Date: Thu, 30 Mar 2017 20:37:43 -0400 Subject: [PATCH 8/9] Update to reflect version change --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f368469..d6cdc7a 100644 --- a/README.md +++ b/README.md @@ -5,8 +5,8 @@ PyCscope :Copyright: Copyright 2013 Peter Portante. See LICENSE for details. :Author: Peter Portante -:Release: 1.2.1 -:Date: 2013/03/16 +:Release: 1.2.2 +:Date: 2017/03/30 Purpose ------- @@ -97,11 +97,13 @@ by the `CscopeFinder` plugin for jEdit. Other editors are not tested. Release Notes ------------- -This is PyCscope release 1.2.1 +This is PyCscope release 1.2.2 ========== ========= ====== ==================================================== Date Release Trac Changes ========== ========= ====== ==================================================== +2017/03/30 1.2.2 N/A Fix Travis tests for 2.6 other testing issues. +---------- --------- ------ ---------------------------------------------------- 2013/03/16 1.2.1 N/A Fix strings-as-symbols support (really). ---------- --------- ------ ---------------------------------------------------- 2013/03/16 1.2 N/A Fix strings-as-symbols support; fix end of function From 382a382bc03b416d4d7401aeee85e4c90efa7a32 Mon Sep 17 00:00:00 2001 From: Hans-Dieter Stich Date: Fri, 24 Feb 2017 13:05:49 +0100 Subject: [PATCH 9/9] Added PR 'Py3K fix for -i option' PR: https://github.com/portante/pycscope/pull/26 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0bf14a0..8205caa 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ dist pycscope.egg-info .ropeproject/ *.pyc +.ropeproject/