소스 검색

Fix issue #8 version awfullness

Matthew Wang 11 년 전
부모
커밋
4bcbeff43d
5개의 변경된 파일35개의 추가작업 그리고 37개의 파일을 삭제
  1. 1
    0
      .gitignore
  2. 6
    2
      CHANGES
  3. 4
    4
      README.rst
  4. 14
    10
      cdiff.py
  5. 10
    21
      setup.py

+ 1
- 0
.gitignore 파일 보기

5
 /build/
5
 /build/
6
 /cdiff.egg-info/
6
 /cdiff.egg-info/
7
 /dist/
7
 /dist/
8
+/__pycache__/

+ 6
- 2
CHANGES 파일 보기

2
 Change log
2
 Change log
3
 ==========
3
 ==========
4
 
4
 
5
+Version 0.2 (2013-02-06)
6
+
7
+  - Move cdiff.py to top dir for better meta info management
8
+
5
 Version 0.1 (2013-02-05)
9
 Version 0.1 (2013-02-05)
6
 
10
 
7
-    - New --version option
8
-    - setup.py now read version from source code
11
+  - New --version option
12
+  - setup.py now read version from source code
9
 
13
 
10
 Version 0.0.4 (2013-02-04)
14
 Version 0.0.4 (2013-02-04)
11
 
15
 

+ 4
- 4
README.rst 파일 보기

43
 
43
 
44
 Both ``pip`` and ``setup.py`` installs cdiff to system wide directory, if you
44
 Both ``pip`` and ``setup.py`` installs cdiff to system wide directory, if you
45
 want a minimal tool without the boring external dependencies (like me), just
45
 want a minimal tool without the boring external dependencies (like me), just
46
-save `src/cdiff.py <https://raw.github.com/ymattw/cdiff/master/src/cdiff.py>`_
47
-to whatever directory which is in your ``$PATH``, for example, ``$HOME/bin`` is
48
-in my ``$PATH``, so I save the script there and name as ``cdiff``.
46
+save `cdiff.py <https://raw.github.com/ymattw/cdiff/master/cdiff.py>`_ to
47
+whatever directory which is in your ``$PATH``, for example, ``$HOME/bin`` is in
48
+my ``$PATH``, so I save the script there and name as ``cdiff``.
49
 
49
 
50
 .. code:: sh
50
 .. code:: sh
51
 
51
 
52
-    curl -ksS https://raw.github.com/ymattw/cdiff/master/src/cdiff.py > ~/bin/cdiff
52
+    curl -ksS https://raw.github.com/ymattw/cdiff/master/cdiff.py > ~/bin/cdiff
53
     chmod +x ~/bin/cdiff
53
     chmod +x ~/bin/cdiff
54
 
54
 
55
 Usage
55
 Usage

src/cdiff.py → cdiff.py 파일 보기

3
 
3
 
4
 """
4
 """
5
 Term based tool to view **colored**, **incremental** diff in *git/svn/hg*
5
 Term based tool to view **colored**, **incremental** diff in *git/svn/hg*
6
-workspace, or diff from given file or stdin, with **side by side** and **auto
7
-pager** support.  Requires python (>= 2.5.0) and ``less``.
8
-
9
-AUTHOR  : Matthew Wang <mattwyl(@)gmail(.)com>
10
-LICENSE : BSD-3
11
-HOMEPAGE: https://github.com/ymattw/cdiff
6
+workspace, given file or stdin, with **side by side** and **auto pager**
7
+support.  Requires python (>= 2.5.0) and ``less``.
12
 """
8
 """
13
 
9
 
10
+META_INFO = {
11
+    'version'     : '0.2',
12
+    'license'     : 'BSD-3',
13
+    'author'      : 'Matthew Wang',
14
+    'email'       : 'mattwyl(@)gmail(.)com',
15
+    'url'         : 'https://github.com/ymattw/cdiff',
16
+    'keywords'    : 'colored incremental side-by-side diff',
17
+    'description' : ('View colored, incremental diff in workspace, given file '
18
+                     'or from stdin, with side by side and auto pager support')
19
+}
20
+
14
 import sys
21
 import sys
15
 
22
 
16
 if sys.hexversion < 0x02050000:
23
 if sys.hexversion < 0x02050000:
25
 import difflib
32
 import difflib
26
 
33
 
27
 
34
 
28
-# REMEMBER UPDATE ``CHANGES``
29
-__version__ = '0.1'
30
-
31
 
35
 
32
 COLORS = {
36
 COLORS = {
33
     'reset'         : '\x1b[0m',
37
     'reset'         : '\x1b[0m',
566
                   'pager support') % '/'.join(supported_vcs)
570
                   'pager support') % '/'.join(supported_vcs)
567
 
571
 
568
     parser = optparse.OptionParser(usage=usage, description=description,
572
     parser = optparse.OptionParser(usage=usage, description=description,
569
-            version='%%prog %s' % __version__)
573
+            version='%%prog %s' % META_INFO['version'])
570
     parser.add_option('-s', '--side-by-side', action='store_true',
574
     parser.add_option('-s', '--side-by-side', action='store_true',
571
             help=('show in side-by-side mode'))
575
             help=('show in side-by-side mode'))
572
     parser.add_option('-w', '--width', type='int', default=80, metavar='N',
576
     parser.add_option('-w', '--width', type='int', default=80, metavar='N',

+ 10
- 21
setup.py 파일 보기

3
 from __future__ import with_statement
3
 from __future__ import with_statement
4
 from distutils.core import setup
4
 from distutils.core import setup
5
 import os
5
 import os
6
+from cdiff import META_INFO as _meta
6
 
7
 
7
 # Create symlink so that to use 'scripts' w/o '.py'
8
 # Create symlink so that to use 'scripts' w/o '.py'
8
 link_name = 'cdiff'
9
 link_name = 'cdiff'
9
 if os.path.exists(link_name):
10
 if os.path.exists(link_name):
10
     os.unlink(link_name)
11
     os.unlink(link_name)
11
-os.symlink('src/cdiff.py', link_name)
12
-
13
-# This awfulness is all in aid of grabbing the version number out
14
-# of the source code, rather than having to repeat it here.  Basically,
15
-# we parse out firt line starts with "__version__" and execute it
16
-#
17
-with open('cdiff') as script:
18
-    for line in script:
19
-        if line.startswith('__version__ = '):
20
-            exec(line)
21
-            break
12
+os.symlink('cdiff.py', link_name)
22
 
13
 
23
 with open('README.rst') as doc:
14
 with open('README.rst') as doc:
24
     long_description = doc.read()
15
     long_description = doc.read()
27
 
18
 
28
 setup(
19
 setup(
29
     name = 'cdiff',
20
     name = 'cdiff',
30
-    version = __version__,
31
-    author = 'Matthew Wang',
32
-    author_email = 'mattwyl(@)gmail(.)com',
33
-    license = 'BSD-3',
34
-    description = ('View colored, incremental diff in workspace, or given '
35
-                   'file from stdin, with side by side and auto pager support'),
21
+    version = _meta['version'],
22
+    author = _meta['author'],
23
+    author_email = _meta['email'],
24
+    license = _meta['license'],
25
+    description = _meta['description'],
36
     long_description = long_description,
26
     long_description = long_description,
37
-    keywords = 'colored incremental side-by-side diff',
38
-    url = 'https://github.com/ymattw/cdiff',
27
+    keywords = _meta['keywords'],
28
+    url = _meta['url'],
39
     classifiers = [
29
     classifiers = [
40
         'Development Status :: 4 - Beta',
30
         'Development Status :: 4 - Beta',
41
         'Topic :: Utilities',
31
         'Topic :: Utilities',
47
         'Operating System :: Unix',
37
         'Operating System :: Unix',
48
         'Programming Language :: Python',
38
         'Programming Language :: Python',
49
     ],
39
     ],
50
-    package_dir = {'': 'src'},
51
-    packages = [''],
40
+    packages = [],
52
     py_modules = ['cdiff'],
41
     py_modules = ['cdiff'],
53
     scripts = [link_name],
42
     scripts = [link_name],
54
 )
43
 )