Selaa lähdekoodia

Read version from source code; add --version; try protect my email from spambot

Matthew Wang 11 vuotta sitten
vanhempi
commit
4f63013531
5 muutettua tiedostoa jossa 35 lisäystä ja 16 poistoa
  1. 5
    0
      CHANGES
  2. 1
    1
      LICENSE
  3. 1
    0
      README.rst
  4. 16
    10
      setup.py
  5. 12
    5
      src/cdiff.py

+ 5
- 0
CHANGES Näytä tiedosto

2
 Change log
2
 Change log
3
 ==========
3
 ==========
4
 
4
 
5
+Version 0.1 (2013-02-05)
6
+
7
+    - New --version option
8
+    - setup.py now read version from source code
9
+
5
 Version 0.0.4 (2013-02-04)
10
 Version 0.0.4 (2013-02-04)
6
 
11
 
7
   - Add CHANGES for history track and better versioning
12
   - Add CHANGES for history track and better versioning

+ 1
- 1
LICENSE Näytä tiedosto

1
 Software License Agreement (BSD-3 License)
1
 Software License Agreement (BSD-3 License)
2
 
2
 
3
-Copyright (c) 2013, Matthew Wang <mattwyl@gmail.com>
3
+Copyright (c) 2013, Matthew Wang <mattwyl(@)gmail(.)com>
4
 All rights reserved.
4
 All rights reserved.
5
 
5
 
6
 Redistribution and use in source and binary forms, with or without modification,
6
 Redistribution and use in source and binary forms, with or without modification,

+ 1
- 0
README.rst Näytä tiedosto

87
     git log -p -2 | cdiff -s
87
     git log -p -2 | cdiff -s
88
     git show 15bfa56 | cdiff -s
88
     git show 15bfa56 | cdiff -s
89
     svn diff -r PREV | cdiff -s
89
     svn diff -r PREV | cdiff -s
90
+    diff -u foo foo.new | cdiff -s
90
 
91
 
91
 Redirect output to another patch file is safe:
92
 Redirect output to another patch file is safe:
92
 
93
 

+ 16
- 10
setup.py Näytä tiedosto

10
     os.unlink(link_name)
10
     os.unlink(link_name)
11
 os.symlink('src/cdiff.py', link_name)
11
 os.symlink('src/cdiff.py', link_name)
12
 
12
 
13
-with open('CHANGES') as changes:
14
-    for change in changes:
15
-        if change.startswith('Version '):
16
-            version = change.split()[1]
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)
17
             break
21
             break
18
-    changes.seek(0)
19
-    with open('README.rst') as doc:
20
-        long_description = doc.read() + changes.read()
22
+
23
+with open('README.rst') as doc:
24
+    long_description = doc.read()
25
+with open('CHANGES') as changes:
26
+    long_description += changes.read()
21
 
27
 
22
 setup(
28
 setup(
23
     name = 'cdiff',
29
     name = 'cdiff',
24
-    version = version,
30
+    version = __version__,
25
     author = 'Matthew Wang',
31
     author = 'Matthew Wang',
26
-    author_email = 'mattwyl@gmail.com',
32
+    author_email = 'mattwyl(@)gmail(.)com',
27
     license = 'BSD-3',
33
     license = 'BSD-3',
28
     description = ('Term based tool to view colored, incremental diff in '
34
     description = ('Term based tool to view colored, incremental diff in '
29
-                   'unified format or side ' 'by side with auto pager'),
35
+                   'unified format or side by side with auto pager'),
30
     long_description = long_description,
36
     long_description = long_description,
31
     keywords = 'colored incremental side-by-side diff',
37
     keywords = 'colored incremental side-by-side diff',
32
     url = 'https://github.com/ymattw/cdiff',
38
     url = 'https://github.com/ymattw/cdiff',

+ 12
- 5
src/cdiff.py Näytä tiedosto

2
 # -*- coding: utf-8 -*-
2
 # -*- coding: utf-8 -*-
3
 
3
 
4
 """
4
 """
5
-View colored, incremental diff in unified format or in side by side mode with
6
-auto pager.  Requires Python (>= 2.5.0) and less.
5
+Term based tool to view colored, incremental diff in unified format or side by
6
+side with auto pager.  Requires Python (>= 2.5.0) and less.
7
 
7
 
8
-See demo at homepage: https://github.com/ymattw/cdiff
8
+AUTHOR  : Matthew Wang <mattwyl(@)gmail(.)com>
9
+LICENSE : BSD-3
10
+HOMEPAGE: https://github.com/ymattw/cdiff
9
 """
11
 """
10
 
12
 
11
 import sys
13
 import sys
22
 import difflib
24
 import difflib
23
 
25
 
24
 
26
 
27
+# REMEMBER UPDATE ``CHANGES``
28
+__version__ = '0.1'
29
+
30
+
25
 COLORS = {
31
 COLORS = {
26
     'reset'         : '\x1b[0m',
32
     'reset'         : '\x1b[0m',
27
     'underline'     : '\x1b[4m',
33
     'underline'     : '\x1b[4m',
519
 
525
 
520
     supported_vcs = [check[0] for check, _ in REVISION_CONTROL]
526
     supported_vcs = [check[0] for check, _ in REVISION_CONTROL]
521
 
527
 
522
-    usage = '%s [options] [diff]' % os.path.basename(sys.argv[0])
528
+    usage = '%prog [options] [diff]'
523
     description= ('View colored, incremental diff in unified format or '
529
     description= ('View colored, incremental diff in unified format or '
524
                   'side by side with auto pager.  Read diff from diff '
530
                   'side by side with auto pager.  Read diff from diff '
525
                   '(patch) file if given, or stdin if redirected, or '
531
                   '(patch) file if given, or stdin if redirected, or '
526
                   'diff produced by revision tool if in a %s workspace') \
532
                   'diff produced by revision tool if in a %s workspace') \
527
             % '/'.join(supported_vcs)
533
             % '/'.join(supported_vcs)
528
 
534
 
529
-    parser = optparse.OptionParser(usage=usage, description=description)
535
+    parser = optparse.OptionParser(usage=usage, description=description,
536
+            version='%%prog %s' % __version__)
530
     parser.add_option('-s', '--side-by-side', action='store_true',
537
     parser.add_option('-s', '--side-by-side', action='store_true',
531
             help=('show in side-by-side mode'))
538
             help=('show in side-by-side mode'))
532
     parser.add_option('-w', '--width', type='int', default=80, metavar='N',
539
     parser.add_option('-w', '--width', type='int', default=80, metavar='N',