anzhi2710gmailcom commited on
Commit
96f168d
·
verified ·
1 Parent(s): 180eacd

Upload folder using huggingface_hub (part 4)

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .gitattributes +11 -0
  2. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/examples/pdb2pqr_web_interface_tutorial-02.png +0 -0
  3. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/examples/pdb2pqr_web_interface_tutorial-03.png +0 -0
  4. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/examples/pdb2pqr_web_interface_tutorial-04.png +0 -0
  5. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/examples/pdb2pqr_web_interface_tutorial-05.png +0 -0
  6. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/README +3 -0
  7. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/__init__.py +117 -0
  8. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/chi.py +70 -0
  9. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/contact.py +80 -0
  10. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/hbond.py +161 -0
  11. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/newresinter.py +354 -0
  12. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/rama.py +102 -0
  13. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/resinter.py +343 -0
  14. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/salt.py +83 -0
  15. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/summary.py +35 -0
  16. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/template +84 -0
  17. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/include/python2.7/pyconfig.h +79 -0
  18. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib/python2.7/config-x86_64-linux-gnu/Makefile +1499 -0
  19. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/__init__.py +1 -0
  20. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/__main__.py +4 -0
  21. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/btm_matcher.py +168 -0
  22. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/btm_utils.py +283 -0
  23. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixer_base.py +189 -0
  24. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixer_util.py +432 -0
  25. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/__init__.py +1 -0
  26. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_apply.py +59 -0
  27. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_basestring.py +14 -0
  28. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_buffer.py +22 -0
  29. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_callable.py +37 -0
  30. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_dict.py +107 -0
  31. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_except.py +93 -0
  32. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_exec.py +40 -0
  33. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_execfile.py +52 -0
  34. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_exitfunc.py +72 -0
  35. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_filter.py +76 -0
  36. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_funcattrs.py +21 -0
  37. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_future.py +22 -0
  38. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_getcwdu.py +19 -0
  39. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_has_key.py +110 -0
  40. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_idioms.py +152 -0
  41. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_import.py +99 -0
  42. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_imports.py +145 -0
  43. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_imports2.py +16 -0
  44. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_input.py +26 -0
  45. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_intern.py +46 -0
  46. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_isinstance.py +52 -0
  47. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_itertools.py +43 -0
  48. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_itertools_imports.py +57 -0
  49. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_long.py +19 -0
  50. model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_map.py +91 -0
.gitattributes CHANGED
@@ -45,3 +45,14 @@ model/comp_surface/tools/transfer/APBS-3.4.1.Linux/share/apbs/tools/bin/similari
45
  model/comp_surface/tools/transfer/APBS-3.4.1.Linux/share/apbs/tools/bin/smooth filter=lfs diff=lfs merge=lfs -text
46
  model/comp_surface/tools/transfer/APBS-3.4.1.Linux/share/apbs/tools/bin/value filter=lfs diff=lfs merge=lfs -text
47
  model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/doc/images/flowchart.png filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
45
  model/comp_surface/tools/transfer/APBS-3.4.1.Linux/share/apbs/tools/bin/smooth filter=lfs diff=lfs merge=lfs -text
46
  model/comp_surface/tools/transfer/APBS-3.4.1.Linux/share/apbs/tools/bin/value filter=lfs diff=lfs merge=lfs -text
47
  model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/doc/images/flowchart.png filter=lfs diff=lfs merge=lfs -text
48
+ model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/libcrypto.so.1.0.0 filter=lfs diff=lfs merge=lfs -text
49
+ model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/libexpat.so.1 filter=lfs diff=lfs merge=lfs -text
50
+ model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/libncursesw.so.5 filter=lfs diff=lfs merge=lfs -text
51
+ model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/libpython2.7.so.1.0 filter=lfs diff=lfs merge=lfs -text
52
+ model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/libreadline.so.6 filter=lfs diff=lfs merge=lfs -text
53
+ model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/libssl.so.1.0.0 filter=lfs diff=lfs merge=lfs -text
54
+ model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/libstdc++.so.6 filter=lfs diff=lfs merge=lfs -text
55
+ model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/libtinfo.so.5 filter=lfs diff=lfs merge=lfs -text
56
+ model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/libz.so.1 filter=lfs diff=lfs merge=lfs -text
57
+ model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/pdb2pqr filter=lfs diff=lfs merge=lfs -text
58
+ model/figs/docking.gif filter=lfs diff=lfs merge=lfs -text
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/examples/pdb2pqr_web_interface_tutorial-02.png ADDED
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/examples/pdb2pqr_web_interface_tutorial-03.png ADDED
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/examples/pdb2pqr_web_interface_tutorial-04.png ADDED
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/examples/pdb2pqr_web_interface_tutorial-05.png ADDED
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/README ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ Please see the programmer's guide (doc/programmerguide.html) for a discussion on how to add your own functionality to PDB2PQR.
2
+
3
+ Additionally, the "template" file is a template for interfacing with PDB2PQR.
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/__init__.py ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Extentions for PDB2PQR Suite
3
+
4
+ This module provides various utilities for the PDB2PQR suite to be
5
+ imported into other Python scripts.
6
+
7
+ ----------------------------
8
+
9
+ PDB2PQR -- An automated pipeline for the setup, execution, and analysis of
10
+ Poisson-Boltzmann electrostatics calculations
11
+
12
+ Copyright (c) 2002-2011, Jens Erik Nielsen, University College Dublin;
13
+ Nathan A. Baker, Battelle Memorial Institute, Developed at the Pacific
14
+ Northwest National Laboratory, operated by Battelle Memorial Institute,
15
+ Pacific Northwest Division for the U.S. Department Energy.;
16
+ Paul Czodrowski & Gerhard Klebe, University of Marburg.
17
+
18
+ All rights reserved.
19
+
20
+ Redistribution and use in source and binary forms, with or without modification,
21
+ are permitted provided that the following conditions are met:
22
+
23
+ * Redistributions of source code must retain the above copyright notice,
24
+ this list of conditions and the following disclaimer.
25
+ * Redistributions in binary form must reproduce the above copyright notice,
26
+ this list of conditions and the following disclaimer in the documentation
27
+ and/or other materials provided with the distribution.
28
+ * Neither the names of University College Dublin, Battelle Memorial Institute,
29
+ Pacific Northwest National Laboratory, US Department of Energy, or University
30
+ of Marburg nor the names of its contributors may be used to endorse or promote
31
+ products derived from this software without specific prior written permission.
32
+
33
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
34
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
35
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
36
+ IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
37
+ INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
38
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
39
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
40
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
41
+ OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
42
+ OF THE POSSIBILITY OF SUCH DAMAGE.
43
+
44
+ ----------------------------
45
+ """
46
+
47
+ import pkgutil
48
+
49
+ from optparse import OptionGroup, OptionConflictError, Option
50
+
51
+ _extList = [name for _, name, _ in pkgutil.iter_modules(__path__)]
52
+
53
+ extDict = {}
54
+
55
+ for extName in _extList:
56
+ extDict[extName] = __import__(extName,globals(),locals(),[], -1)
57
+
58
+ def setupExtensionsOptions(parser):
59
+ """
60
+ Takes an instance of an OptionParser
61
+ and adds the options for all extensions
62
+
63
+ If an extension adds it's own options, those
64
+ options are put in their own group.
65
+ """
66
+
67
+ if len(extDict) == 0:
68
+ return None
69
+
70
+ firstGroup = OptionGroup(parser,"Extension options")
71
+ groups = [firstGroup]
72
+
73
+ for extName, extModule in extDict.items():
74
+ helpArg = {}
75
+ if hasattr(extModule, 'usage'):
76
+ helpArg['help'] = extModule.usage()
77
+
78
+ extOption = Option('--' + extName, action='append_const',
79
+ const = extName, dest = 'active_extensions', **helpArg )
80
+
81
+ try:
82
+ if hasattr(extModule, 'addExtensionOptions'):
83
+ group = OptionGroup(parser, extName.capitalize() + " extension options")
84
+ group.add_option(extOption)
85
+
86
+ extModule.addExtensionOptions(group)
87
+
88
+ if len(group.option_list) == 1:
89
+ opt = group.option_list[0]
90
+ group.remove_option(opt.get_opt_string())
91
+ firstGroup.add_option(opt)
92
+ else:
93
+ groups.append(group)
94
+
95
+ else:
96
+ firstGroup.add_option(extOption)
97
+
98
+ except OptionConflictError, value:
99
+ print 'Error adding command line options for extension ' + extName + ' ' + '(' + str(value) + ')'
100
+
101
+
102
+ for group in groups:
103
+ parser.add_option_group(group)
104
+
105
+ return groups
106
+
107
+ class extOutputHelper(object):
108
+ """
109
+ Simple class that makes writing to both file and output simple.
110
+ """
111
+ def __init__(self, routines, outfile):
112
+ self.routines = routines
113
+ self.outfile = outfile
114
+
115
+ def write(self, s):
116
+ self.routines.write(s)
117
+ self.outfile.write(s)
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/chi.py ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Chi extension
3
+
4
+ Print the backbone chi angle for each residue in the structure.
5
+ Chi angle is determined by the coordinates of the N, CA, CB (if
6
+ available), and CG/OG/SG atoms (if available).
7
+
8
+ Author: Todd Dolinsky
9
+ """
10
+
11
+ __date__ = "17 February 2006"
12
+ __author__ = "Todd Dolinsky"
13
+
14
+ from src.utilities import getDihedral
15
+
16
+ def usage():
17
+ return 'Print the per-residue backbone chi angle to {output-path}.chi'
18
+
19
+ def run_extension(routines, outroot, options):
20
+ """
21
+ Print the list of psi angles
22
+
23
+ Parameters
24
+ routines: A link to the routines object
25
+ outroot: The root of the output name
26
+ options: options object
27
+ """
28
+
29
+ outname = outroot + ".chi"
30
+ outfile = open(outname, "w")
31
+
32
+ routines.write("\nPrinting chi angles for each residue...\n")
33
+ routines.write("Residue chi\n")
34
+ routines.write("----------------\n")
35
+
36
+ # Initialize some variables
37
+
38
+ protein = routines.protein
39
+
40
+ for residue in protein.getResidues():
41
+ if residue.hasAtom("N"):
42
+ ncoords = residue.getAtom("N").getCoords()
43
+ else:
44
+ continue
45
+
46
+ if residue.hasAtom("CA"):
47
+ cacoords = residue.getAtom("CA").getCoords()
48
+ else:
49
+ continue
50
+
51
+ if residue.hasAtom("CB"):
52
+ cbcoords = residue.getAtom("CB").getCoords()
53
+ else:
54
+ continue
55
+
56
+ if residue.hasAtom("CG"):
57
+ gcoords = residue.getAtom("CG").getCoords()
58
+ elif residue.hasAtom("OG"):
59
+ gcoords = residue.getAtom("OG").getCoords()
60
+ elif residue.hasAtom("SG"):
61
+ gcoords = residue.getAtom("SG").getCoords()
62
+ else:
63
+ continue
64
+
65
+ chi = getDihedral(ncoords, cacoords, cbcoords, gcoords)
66
+ routines.write("%s\t%.4f\n" % (residue, chi))
67
+ outfile.write("%s\t%.4f\n" % (residue, chi))
68
+
69
+ routines.write("\n")
70
+ outfile.close()
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/contact.py ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Contact extension
3
+
4
+ Find all hydrogen bonds as determined by the DISTANCE cutoff below.
5
+ Uses PDB2PQR to determine donors and acceptors, and displays
6
+ all available bonds to stdout in a WHATIF-like format.
7
+
8
+ Author: Julie C. Mitchell
9
+ """
10
+
11
+ __date__ = "April 2007"
12
+ __author__ = "Julie C. Mitchell"
13
+
14
+ from src.utilities import distance
15
+ from src.routines import Cells
16
+
17
+ DIST_CUTOFF = 3.5 # max distance
18
+
19
+ def usage():
20
+ return 'Print a list of contacts to {output-path}.con\n'
21
+
22
+ def run_extension(routines, outroot, options):
23
+ """
24
+ Print a list of contacts.
25
+
26
+ Parameters
27
+ routines: A link to the routines object
28
+ outroot: The root of the output name
29
+ options: options object
30
+ """
31
+ outname = outroot + ".con"
32
+ outfile = open(outname, "w")
33
+
34
+ # Initialize - set nearby cells, donors/acceptors
35
+
36
+ cellsize = int(DIST_CUTOFF + 1.0 + 1.0)
37
+ protein = routines.protein
38
+ routines.setDonorsAndAcceptors()
39
+ routines.cells = Cells(cellsize)
40
+ routines.cells.assignCells(protein)
41
+
42
+ for thisatom in protein.getAtoms():
43
+ # Grab the list of thisatoms
44
+ if not thisatom.hdonor:
45
+ continue
46
+ thisatomhs = []
47
+ for bond in thisatom.bonds:
48
+ if bond.isHydrogen():
49
+ thisatomhs.append(bond)
50
+ if thisatomhs == []:
51
+ continue
52
+
53
+ # For each thisatom, grab all thatatomeptors
54
+
55
+ count = 0
56
+ closeatoms = routines.cells.getNearCells(thisatom)
57
+ for thatatom in closeatoms:
58
+ if (thisatom.residue == thatatom.residue):
59
+ continue # comment this out to include interresidue contacts
60
+ if (thatatom.isHydrogen()):
61
+ continue
62
+ thisdist = distance(thisatom.getCoords(), thatatom.getCoords())
63
+ if (thisdist <= DIST_CUTOFF):
64
+ count = count+1
65
+ thisBstring='S'
66
+ thatBstring='S'
67
+ hscore= 0.0
68
+ if (thisatom.hdonor & thatatom.hacceptor):
69
+ hscore = 1.0
70
+ if (thisatom.hacceptor & thatatom.hdonor):
71
+ hscore = 1.0
72
+ if (thisatom.isBackbone()):
73
+ thisBstring='B'
74
+ if (thatatom.isBackbone()):
75
+ thatBstring='B'
76
+ outfile.write("%4d %4d %-4s (%4d ) %s %-4s<>%4d %-4s (%4d ) %s %-4s D=%6.2f H-ene=%6.2f Sym= (%s-%s)\n" % \
77
+ (count, thisatom.residue.resSeq,thisatom.residue.name,thisatom.residue.resSeq, thisatom.residue.chainID,thisatom.name,thatatom.residue.resSeq,thatatom.residue.name,thatatom.residue.resSeq, thatatom.residue.chainID,thatatom.name, thisdist, hscore, thisBstring, thatBstring))
78
+
79
+ routines.write("\n")
80
+ outfile.close()
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/hbond.py ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Hbond extension
3
+
4
+ Find all hydrogen bonds as determined by the cutoffs specified.
5
+ Uses PDB2PQR to determine donors and acceptors, and displays
6
+ all available bonds to file.
7
+
8
+ The original bonding parameters were an angle of 20.0,
9
+ distance of 3.30, and using the old method for calculating
10
+ distance.
11
+
12
+ The original parameters for WHAT-IF output was an angle of
13
+ 90.0, distance of 3.30, and using the old method for
14
+ calculating distance.
15
+
16
+ Authors: Todd Dolinsky, Michael J Bradley, Julie Mitchell, and Kyle Monson
17
+ """
18
+
19
+ __date__ = "17 February 2006"
20
+ __author__ = "Todd Dolinsky, Michael J Bradley, Julie Mitchell, and Kyle Monson"
21
+ # NOTE: This extension edited and updated on 05 August 2008 by Michael J Bradley
22
+ # and again on 17 October by Kyle Monson.
23
+
24
+ # NOTE: The current defaults for hbonds used below were utilized in the following study:
25
+ #Bradley MJ, Chivers PT, Baker NA. Molecular dynamics simulation of the
26
+ #Escherichia coli NikR protein: Equilibrium conformational fluctuations reveal
27
+ #inter-domain allosteric communication pathways. Journal of Molecular Biology, 378,
28
+ #1155-1173, 2008. http://dx.doi.org/10.1016/j.jmb.2008.03.010
29
+
30
+ from src.utilities import distance, getAngle
31
+ from src.routines import Cells
32
+ from math import cos
33
+ import extensions
34
+
35
+ ANGLE_CUTOFF = 30.0 # A - D - H(D) angle
36
+ DIST_CUTOFF = 3.4 # D to A distance
37
+
38
+ def addExtensionOptions(extensionGroup):
39
+ """
40
+ Add options to set output type, angle cutoff, distance cutoff, and distance calculating method.
41
+ """
42
+ extensionGroup.add_option('--whatif', dest='whatif', action='store_true', default=False,
43
+ help='Change hbond output to WHAT-IF format.')
44
+
45
+ extensionGroup.add_option('--angle_cutoff', dest='angle_cutoff', type="float", action='store', default=ANGLE_CUTOFF,
46
+ help='Angle cutoff to use when creating hbond data (default %s)' % ANGLE_CUTOFF)
47
+
48
+ extensionGroup.add_option('--distance_cutoff', dest='distance_cutoff', type="float", action='store', default=DIST_CUTOFF,
49
+ help='Distance cutoff to use when creating hbond data (default %s)' % DIST_CUTOFF)
50
+
51
+ extensionGroup.add_option('--old_distance_method', dest='old_distance_method', action='store_true', default=False,
52
+ help='Use distance from donor hydrogen to acceptor to calculate distance used with --distance_cutoff.')
53
+
54
+ def usage():
55
+ return 'Print a list of hydrogen bonds to {output-path}.hbond'
56
+
57
+ #TODO: replace this with a ''.format() call.
58
+ def _residueString(residue, name):
59
+ return '%4d %-4s (%4d ) %s %-4s' % \
60
+ (residue.resSeq, residue.name, residue.resSeq, residue.chainID, name)
61
+
62
+ def create_hbond_output(routines, outfile, whatif=False,
63
+ angleCutoff=ANGLE_CUTOFF,
64
+ distanceCutoff=DIST_CUTOFF,
65
+ oldDistanceMethod=False):
66
+
67
+ routines.write("Printing hydrogen bond list...\n")
68
+
69
+ output = extensions.extOutputHelper(routines, outfile)
70
+
71
+ cellsize = int(distanceCutoff + 1.0 + 1.0)
72
+ protein = routines.protein
73
+ routines.setDonorsAndAcceptors()
74
+ routines.cells = Cells(cellsize)
75
+ routines.cells.assignCells(protein)
76
+
77
+ for donor in protein.getAtoms():
78
+
79
+ # Grab the list of donors
80
+ if not donor.hdonor:
81
+ continue
82
+ donorhs = []
83
+ for bond in donor.bonds:
84
+ if bond.isHydrogen():
85
+ donorhs.append(bond)
86
+ if donorhs == []:
87
+ continue
88
+
89
+ # For each donor, grab all acceptors
90
+ closeatoms = routines.cells.getNearCells(donor)
91
+ for acc in closeatoms:
92
+ if not acc.hacceptor:
93
+ continue
94
+ if donor.residue == acc.residue:
95
+ continue
96
+
97
+ #TODO: do we need to do this for plain hbond stuff?
98
+ if whatif and (donor.residue.chainID == acc.residue.chainID):
99
+ continue
100
+
101
+ # Do new style distance check
102
+ if not oldDistanceMethod:
103
+ dist = distance(donor.getCoords(), acc.getCoords())
104
+ if dist > distanceCutoff:
105
+ continue
106
+
107
+ for donorh in donorhs:
108
+
109
+ # Do old style distance check
110
+ if oldDistanceMethod:
111
+ dist = distance(donorh.getCoords(), acc.getCoords())
112
+ if dist > distanceCutoff:
113
+ continue
114
+
115
+ # Do angle check
116
+ angle = getAngle(acc.getCoords(), donor.getCoords(), donorh.getCoords())
117
+ if angle > angleCutoff:
118
+ continue
119
+
120
+ if whatif:
121
+ if (donor.tempFactor > 60.0):
122
+ continue
123
+ if (acc.tempFactor > 60.0):
124
+ continue
125
+
126
+ thisBstring='B' if donor.isBackbone() else 'S'
127
+ thatBstring='B' if acc.isBackbone() else 'S'
128
+
129
+ score= (1.7/dist) * cos(angle * 3.142 / 180.0)
130
+ output.write(_residueString(donor.residue, donor.name))
131
+ output.write('-> ')
132
+ output.write(_residueString(acc.residue, acc.name))
133
+ output.write('Sym= 1 Val= %6.3lf DA=%6.2f DHA=%6.2f (%s-%s)\n' %
134
+ (score, dist, angle, thisBstring, thatBstring))
135
+ # outfile.write("%4d %-4s (%4d ) %s %-4s-> %4d %-4s (%4d ) %s %-4sSym= 1 Val= %6.3lf DA=%6.2f DHA=%6.2f (%s-%s)\n" % \
136
+ # (donor.residue.resSeq,donor.residue.name,donor.residue.resSeq, donor.residue.chainID,donor.name,acc.residue.resSeq,acc.residue.name,acc.residue.resSeq, acc.residue.chainID,acc.name, score, dist, angle, thisBstring, thatBstring))
137
+
138
+ else:
139
+ s = "Donor: %s %s\tAcceptor: %s %s\tdist: %.2f\tAngle: %.2f\n" % \
140
+ (donor.residue, donor.name, acc.residue, acc.name, dist, angle)
141
+ output.write(s)
142
+
143
+ routines.write("\n")
144
+
145
+ def run_extension(routines, outroot, options):
146
+ """
147
+ Print a list of hydrogen bonds.
148
+
149
+ Parameters
150
+ routines: A link to the routines object
151
+ outroot: The root of the output name
152
+ options: options object
153
+ """
154
+
155
+ outname = outroot + ".hbond"
156
+ with open(outname, "w") as outfile:
157
+ create_hbond_output(routines, outfile, whatif=options.whatif,
158
+ angleCutoff=options.angle_cutoff,
159
+ distanceCutoff=options.distance_cutoff,
160
+ oldDistanceMethod=options.old_distance_method)
161
+
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/newresinter.py ADDED
@@ -0,0 +1,354 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Resinter extension
3
+
4
+ Print interaction energy between each residue pair in the protein.
5
+ """
6
+
7
+ __date__ = "21 October 2011"
8
+ __authors__ = "Kyle Monson and Emile Hogan"
9
+
10
+ import extensions
11
+ from src.hydrogens import Optimize
12
+ #itertools FTW!
13
+ from itertools import product, permutations, izip, count
14
+ from src.hydrogens import hydrogenRoutines
15
+
16
+ #Here are the Ri -> [Ri0, Ri1] maps:
17
+ #ARG -> [{AR0}, {ARG}]
18
+ #ASP -> [{ASP}, {ASH}]
19
+ #GLU -> [{GLU}, {GLH}]
20
+ #CYS -> [{CYM}, {CYS}]
21
+ #LYS -> [{LYN}, {LYS}]
22
+ #TYR -> [{TYM}, {TYR}]
23
+ #CTERM -> [{CTERM}, {NEUTRAL-CTERM}]
24
+ #NTERM -> [{NEUTRAL-NTERM}, {NTERM}]
25
+ #HIS -> [{HSD, HSE}, {HIS}]
26
+ #HIP -> [{HID, HIE}, {HIP}]
27
+ #HSP -> [{HSD, HSE}, {HSP}]
28
+
29
+ _titrationSets = ((('AR0',), 'ARG'),
30
+ (('ASH',), 'ASP'),
31
+ (('CYX',), 'CYS'),
32
+ (('GLU',), 'GLH'),
33
+ (('HSD', 'HSE'), 'HSP'),
34
+ (('HID', 'HIE'), 'HIP'),
35
+ (('LYN',), 'LYS'),
36
+ (('TYM',), 'TYR'),
37
+ (('CTERM',), 'NEUTRAL-CTERM'),
38
+ (('NEUTRAL-NTERM',), 'NTERM'))
39
+
40
+ _titrationSetsMap = {}
41
+
42
+ for tsSet in _titrationSets:
43
+ for ts in tsSet[0]:
44
+ _titrationSetsMap[ts] = tsSet
45
+
46
+ _titrationSetsMap[tsSet[1]] = tsSet
47
+
48
+ #loose ends.
49
+ _titrationSetsMap['HIS'] = _titrationSetsMap['HSD']
50
+ _titrationSetsMap['CYM'] = _titrationSetsMap['CYS']
51
+
52
+ def usage():
53
+ """
54
+ Returns usage text for newresinter.
55
+ """
56
+ txt = 'Print interaction energy between each residue pair in the protein to {output-path}.newresinter.'
57
+ return txt
58
+
59
+ def run_extension(routines, outroot, options):
60
+ outname = outroot + ".newresinter"
61
+ with open(outname, "w") as outfile:
62
+ processor = ResInter(routines, outfile, options)
63
+ processor.generate_all()
64
+ processor.write_resinter_output()
65
+
66
+ class ResInter(object):
67
+ def __init__(self, routines, outfile, options):
68
+ self.pairEnergyResults = {}
69
+ self.combinationCount = 0
70
+ self.totalCombinations = 0
71
+ self.options = options
72
+ self.output = extensions.extOutputHelper(routines, outfile)
73
+ self.routines = routines
74
+
75
+ def save_interation_energy(self, first, second):
76
+ energy = get_residue_interaction_energy(first, second)
77
+ pairText = str(first) + ' ' + str(second)
78
+ if pairText in self.pairEnergyResults:
79
+ txt = '#%s re-tested!!! LOLWAT?\n' % pairText
80
+ self.output.write(txt)
81
+ else:
82
+ self.pairEnergyResults[pairText] = energy
83
+
84
+
85
+ def save_all_residue_interaction_energies(self):
86
+ """
87
+ Writes out the residue interaction energy for each possible
88
+ residue pair in the protein.
89
+ """
90
+ residuepairs = permutations(self.routines.protein.getResidues(), 2)
91
+
92
+ for pair in residuepairs:
93
+ self.save_interation_energy(pair[0], pair[1])
94
+
95
+ def save_one_with_all_interaction_energies(self, i):
96
+ """
97
+ Writes out the residue interaction energy for each possible
98
+ residue pair in the protein.
99
+ """
100
+ residues = list(self.routines.protein.getResidues())
101
+ target = residues[i]
102
+ del residues[i]
103
+
104
+ for residue in residues:
105
+ self.save_interation_energy(target, residue)
106
+ self.save_interation_energy(residue, target)
107
+
108
+ def save_pair_interaction_energies(self, i, j):
109
+ """
110
+ Writes out the residue interaction energy for each possible
111
+ residue pair in the protein.
112
+ """
113
+ residues = list(self.routines.protein.getResidues())
114
+
115
+ self.save_interation_energy(residues[i], residues[j])
116
+ self.save_interation_energy(residues[j], residues[i])
117
+
118
+ def create_all_protonated(self):
119
+ residueSet = get_residue_titration_set_protonated(self.routines.protein.getResidues())
120
+ self.process_residue_set(residueSet,
121
+ clean = self.options.clean,
122
+ neutraln = self.options.neutraln,
123
+ neutralc = self.options.neutralc,
124
+ ligand = self.options.ligand,
125
+ assign_only = self.options.assign_only,
126
+ chain = self.options.chain,
127
+ debump = self.options.debump,
128
+ opt = self.options.opt)
129
+
130
+ self.save_all_residue_interaction_energies()
131
+
132
+ def create_all_single_unprotonated(self):
133
+ combinations = residue_set_single_unprotonated_combinations(self.routines.protein.getResidues())
134
+ for residueSet, i in combinations:
135
+ self.process_residue_set(residueSet,
136
+ clean = self.options.clean,
137
+ neutraln = self.options.neutraln,
138
+ neutralc = self.options.neutralc,
139
+ ligand = self.options.ligand,
140
+ assign_only = self.options.assign_only,
141
+ chain = self.options.chain,
142
+ debump = self.options.debump,
143
+ opt = self.options.opt)
144
+
145
+ self.save_one_with_all_interaction_energies(i)
146
+
147
+ def create_all_pair_unprotonated(self):
148
+ combinations = residue_set_pair_unprotonated_combinations(self.routines.protein.getResidues())
149
+ for residueSet, i, j in combinations:
150
+ self.process_residue_set(residueSet,
151
+ clean = self.options.clean,
152
+ neutraln = self.options.neutraln,
153
+ neutralc = self.options.neutralc,
154
+ ligand = self.options.ligand,
155
+ assign_only = self.options.assign_only,
156
+ chain = self.options.chain,
157
+ debump = self.options.debump,
158
+ opt = self.options.opt)
159
+
160
+ self.save_pair_interaction_energies(i, j)
161
+
162
+ def count_combinations(self):
163
+ n = 0 # total iterable residues
164
+ k = 0 # total iterable residues with two possible choices.
165
+
166
+ allProtonated = get_residue_titration_set_protonated(self.routines.protein.getResidues())
167
+
168
+ for name in allProtonated:
169
+ if name in _titrationSetsMap:
170
+ n += 1
171
+
172
+ if len(_titrationSetsMap[name][0]) == 2:
173
+ k += 1
174
+
175
+ self.totalCombinations = (((n+k)**2)+(n-k)+2)/2
176
+
177
+ def generate_all(self):
178
+ """
179
+ For every titration state combination of residue output the
180
+ interaction energy for all possible residue pairs.
181
+ """
182
+ self.routines.write("Printing residue interaction energies...\n")
183
+
184
+ self.count_combinations()
185
+
186
+ #Phase 1: Everything protonated
187
+ self.create_all_protonated()
188
+
189
+ #Phase 2: Single unprotonated paired with everything else.
190
+ self.create_all_single_unprotonated()
191
+
192
+ #Phase 2: Pair unprotonated paired with each other.
193
+ self.create_all_pair_unprotonated()
194
+
195
+ def write_resinter_output(self):
196
+ """
197
+ Output the interaction energy between each possible residue pair.
198
+ """
199
+ for resultKey in sorted(self.pairEnergyResults.iterkeys()):
200
+ self.output.write(resultKey + ' ' + str(self.pairEnergyResults[resultKey]) + '\n')
201
+
202
+ self.routines.write(str(self.combinationCount)+' residue combinations tried\n')
203
+
204
+ def process_residue_set(self, residueSet,
205
+ clean = False,
206
+ neutraln = False,
207
+ neutralc = False,
208
+ ligand = None,
209
+ assign_only = False,
210
+ chain = False,
211
+ debump = True,
212
+ opt = True):
213
+
214
+ self.combinationCount += 1
215
+
216
+ txt = "Running combination {0} of {1}\n".format(self.combinationCount, self.totalCombinations)
217
+ self.routines.write(txt)
218
+
219
+ self.routines.write(str(residueSet)+'\n')
220
+
221
+ self.routines.removeHydrogens()
222
+
223
+ for newResidueName, oldResidue, index in izip(residueSet, self.routines.protein.getResidues(), count()):
224
+ if newResidueName is None:
225
+ continue
226
+
227
+ chain = self.routines.protein.chainmap[oldResidue.chainID]
228
+ chainIndex = chain.residues.index(oldResidue)
229
+ residueAtoms = oldResidue.atoms
230
+
231
+ #Create the replacement residue
232
+ newResidue = self.routines.protein.createResidue(residueAtoms, newResidueName)
233
+
234
+ #Make sure our names are cleaned up for output.
235
+ newResidue.renameResidue(newResidueName)
236
+
237
+ #Drop it in
238
+ self.routines.protein.residues[index] = newResidue
239
+ chain.residues[chainIndex] = newResidue
240
+
241
+ #Run the meaty bits of PDB2PQR
242
+ self.routines.setTermini(neutraln, neutralc)
243
+ self.routines.updateBonds()
244
+
245
+ if not clean and not assign_only:
246
+ self.routines.updateSSbridges()
247
+
248
+ if debump:
249
+ self.routines.debumpProtein()
250
+
251
+ self.routines.addHydrogens()
252
+
253
+ hydRoutines = hydrogenRoutines(self.routines)
254
+
255
+ if debump:
256
+ self.routines.debumpProtein()
257
+
258
+ if opt:
259
+ hydRoutines.setOptimizeableHydrogens()
260
+ hydRoutines.initializeFullOptimization()
261
+ hydRoutines.optimizeHydrogens()
262
+ else:
263
+ hydRoutines.initializeWaterOptimization()
264
+ hydRoutines.optimizeHydrogens()
265
+
266
+ # Special for GLH/ASH, since both conformations were added
267
+ hydRoutines.cleanup()
268
+
269
+
270
+ def get_residue_titration_set_protonated(residues):
271
+ """
272
+ Returns residue set when everything is protonated.
273
+ """
274
+ result = []
275
+ for residue in residues:
276
+ residueTest = _titrationSetsMap.get(residue.name)
277
+ if residueTest:
278
+ residueTest = residueTest[1]
279
+ else:
280
+ residueTest = residue.name
281
+ result.append(residueTest)
282
+
283
+ return result
284
+
285
+ def residue_set_single_unprotonated_combinations(residues):
286
+ """
287
+ Yields pair (residue set, residue index) for
288
+ every "single unprotonated" combination.
289
+ residue set - set for process_residue_set
290
+ residue index - index of residue that was left unprotonated
291
+ """
292
+ protonatedNames = get_residue_titration_set_protonated(residues)
293
+
294
+ for name, i in izip(protonatedNames, count()):
295
+ if not name in _titrationSetsMap:
296
+ continue
297
+
298
+ tStateSet = _titrationSetsMap[name][0]
299
+
300
+ for tState in tStateSet:
301
+ result = list(protonatedNames)
302
+ result[i] = tState
303
+ yield result, i
304
+
305
+ def residue_set_pair_unprotonated_combinations(residues):
306
+ """
307
+ Yields pair (residue set, 1rst residue index, 2nd residue index) for
308
+ every "single unprotonated" combination.
309
+ residue set - set for process_residue_set
310
+ 1rst residue index - index of 1rst residue that was left unprotonated
311
+ 2nd residue index - index of 2nd residue that was left unprotonated
312
+ """
313
+ protonatedNames = get_residue_titration_set_protonated(residues)
314
+
315
+ for i in xrange(0,len(protonatedNames)):
316
+ firstName = protonatedNames[i]
317
+ if not firstName in _titrationSetsMap:
318
+ continue
319
+ firstStateSet = _titrationSetsMap[firstName][0]
320
+ for j in xrange(0,i):
321
+ secondName = protonatedNames[j]
322
+ if not secondName in _titrationSetsMap:
323
+ continue
324
+
325
+ secondStateSet = _titrationSetsMap[secondName][0]
326
+
327
+ for firstState in firstStateSet:
328
+ for secondState in secondStateSet:
329
+ result = list(protonatedNames)
330
+ result[i] = firstState
331
+ result[j] = secondState
332
+ yield result, i, j
333
+
334
+
335
+ def get_residue_interaction_energy(residue1, residue2):
336
+ """
337
+ Returns to total energy of every atom pair between the two residues.
338
+
339
+ Uses Optimize.getPairEnergy and it's donor/accepter model
340
+ to determine energy.
341
+
342
+ residue1 - "donor" residue
343
+ residue2 - "acceptor" residue
344
+
345
+ THE RESULTS OF THIS FUNCTION ARE NOT SYMMETRIC. Swapping
346
+ residue1 and residue2 will not always produce the same result.
347
+ """
348
+ energy = 0.0
349
+ for pair in product(residue1.getAtoms(), residue2.getAtoms()):
350
+ energy += Optimize.getPairEnergy(pair[0], pair[1])
351
+
352
+ return energy
353
+
354
+
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/rama.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Ramachandran extension
3
+
4
+ Print both the phi and psi angles to standard out. See the individual
5
+ functions for more info.
6
+
7
+ Author: Mike Bradley and Todd Dolinsky
8
+ """
9
+
10
+ __date__ = "17 February 2006"
11
+ __author__ = "Mike Bradley, Todd Dolinsky"
12
+
13
+ from src.utilities import getDihedral
14
+ import extensions
15
+
16
+ def addExtensionOptions(extensionGroup):
17
+ """
18
+ Add options to set output type.
19
+ """
20
+ extensionGroup.parser.set_defaults(rama_output='rama')
21
+ extensionGroup.add_option('--phi_only', dest='rama_output', action='store_const', const = 'phi',
22
+ help='Only include phi angles in output. '+
23
+ 'Rename output file {output-path}.phi')
24
+
25
+ extensionGroup.add_option('--psi_only', dest='rama_output', action='store_const', const = 'psi',
26
+ help='Only include psi angles in output. '+
27
+ 'Rename output file {output-path}.psi')
28
+
29
+
30
+ def usage():
31
+ return 'Print the per-residue phi and psi angles to {output-path}.rama for Ramachandran plots'
32
+
33
+ def create_rama_output(routines, outfile, outputtype='rama'):
34
+
35
+ routines.write("\nPrinting %s angles for each residue...\n" % (outputtype if outputtype != 'rama' else 'phi and psi'))
36
+ verboseHeader = "Residue %s\n" % (outputtype.capitalize() if outputtype != 'rama' else 'Phi Psi')
37
+ routines.write(verboseHeader)
38
+ routines.write('-' * len(verboseHeader) + '\n')
39
+
40
+ output = extensions.extOutputHelper(routines, outfile)
41
+
42
+ # Initialize some variables
43
+
44
+ protein = routines.protein
45
+
46
+ for residue in protein.getResidues():
47
+ if residue.hasAtom("N"):
48
+ ncoords = residue.getAtom("N").getCoords()
49
+ else:
50
+ continue
51
+
52
+ if residue.hasAtom("CA"):
53
+ cacoords = residue.getAtom("CA").getCoords()
54
+ else:
55
+ continue
56
+
57
+ if residue.hasAtom("C"):
58
+ ccoords = residue.getAtom("C").getCoords()
59
+ else:
60
+ continue
61
+
62
+ try:
63
+ if residue.peptideN != None:
64
+ pepncoords = residue.peptideN.getCoords()
65
+ else:
66
+ continue
67
+
68
+ if residue.peptideC != None:
69
+ pepccoords = residue.peptideC.getCoords()
70
+ else:
71
+ continue
72
+ except AttributeError: # Non amino acids
73
+ continue
74
+
75
+ output.write(str(residue))
76
+
77
+ if outputtype in ('rama', 'phi'):
78
+ phi = getDihedral(pepccoords, ncoords, cacoords, ccoords)
79
+ output.write("\t%.4f" % phi)
80
+
81
+ if outputtype in ('rama', 'psi'):
82
+ psi = getDihedral(ncoords, cacoords, ccoords, pepncoords)
83
+ output.write("\t%.4f" % psi)
84
+
85
+ output.write('\n')
86
+
87
+ routines.write("\n")
88
+
89
+ def run_extension(routines, outroot, options):
90
+ """
91
+ Print the list of phi and psi angles for use in a Ramachandran plot.
92
+
93
+ Parameters
94
+ routines: A link to the routines object
95
+ outroot: The root of the output name
96
+ options: options object
97
+ """
98
+ outputType = options.rama_output
99
+ outname = outroot + '.' + outputType
100
+ with open(outname, "w") as outfile:
101
+ create_rama_output(routines, outfile, outputtype=outputType)
102
+
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/resinter.py ADDED
@@ -0,0 +1,343 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Resinter extension
3
+
4
+ Print interaction energy between each residue pair in the protein.
5
+ """
6
+
7
+ __date__ = "21 October 2011"
8
+ __authors__ = "Kyle Monson and Emile Hogan"
9
+
10
+ import extensions
11
+ from src.hydrogens import Optimize
12
+ #itertools FTW!
13
+ from itertools import product, permutations, izip, count
14
+ from collections import defaultdict
15
+ from src.hydrogens import hydrogenRoutines
16
+
17
+ _titrationSets = (('ARG','AR0'),
18
+ ('ASP', 'ASH'),
19
+ ('CYS', 'CYX'),
20
+ ('GLU', 'GLH'),
21
+ ('HSD', 'HSE', 'HSP'),
22
+ ('HID', 'HIE', 'HIP'),
23
+ ('LYN', 'LYS'),
24
+ ('TYR', 'TYM'),
25
+ ('NEUTRAL-CTERM', 'CTERM'),
26
+ ('NEUTRAL-NTERM', 'NTERM'))
27
+
28
+ _titrationSetsMap = defaultdict(tuple)
29
+
30
+ for tsSet in _titrationSets:
31
+ for ts in tsSet:
32
+ _titrationSetsMap[ts] = tsSet
33
+
34
+ #loose ends.
35
+ _titrationSetsMap['HIS'] = _titrationSetsMap['HSD']
36
+ _titrationSetsMap['CYM'] = _titrationSetsMap['CYS']
37
+
38
+ _pairEnergyResults = {}
39
+ #If the residue pair energy for a specific pair changes less than this ignore it.
40
+ PAIR_ENERGY_EPSILON = 1.0e-14
41
+
42
+ def addExtensionOptions(extensionGroup):
43
+ """
44
+ Add options.
45
+ """
46
+ extensionGroup.add_option('--residue_combinations',
47
+ dest='residue_combinations',
48
+ action='store_true',
49
+ default=False,
50
+ help=
51
+ '''Remap residues to different titration states and rerun resinter appending output.
52
+ Consider only the minimum number of whole protein titration combinations needed to
53
+ test each possible pairing of residue titration states. Normally used with
54
+ --noopt. If a protein titration state combination results in a pair of residue being
55
+ re-tested in the same individual titration states a warning will be generated if the
56
+ re-tested result is different. This warning should not be possible if used with --noopt.''')
57
+
58
+ extensionGroup.add_option('--all_residue_combinations',
59
+ dest='all_residue_combinations',
60
+ action='store_true',
61
+ default=False,
62
+ help=
63
+ '''Remap residues to ALL possible titration state combinations and rerun resinter appending output.
64
+ Results with --noopt should be the same as --residue_combinations. Runs considerably slower than
65
+ --residue_combinations and generates the same type of warnings.
66
+ Use without --noopt to discover how hydrogen optimization affects residue
67
+ interaction energies via the warnings in the output.''')
68
+
69
+ def usage():
70
+ """
71
+ Returns usage text for resinter.
72
+ """
73
+ txt = 'Print interaction energy between each residue pair in the protein to {output-path}.resinter.'
74
+ return txt
75
+
76
+ def _combinations(sublist, remainder):
77
+ """
78
+ combinations function helper
79
+
80
+ sublist - first list in list of lists for combinations
81
+ remainder - list of remaining lists
82
+ """
83
+ if remainder and sublist:
84
+ for item in sublist:
85
+ for result in _combinations(remainder[0], remainder[1:]):
86
+ yield [item] + result
87
+ return
88
+ elif sublist:
89
+ for item in sublist:
90
+ yield [item]
91
+ return
92
+ elif remainder:
93
+ for result in _combinations(remainder[0], remainder[1:]):
94
+ yield [None] + result
95
+ return
96
+
97
+ yield [None]
98
+
99
+ def combinations(initialList):
100
+ """
101
+ Wrapper for main combinations function.
102
+
103
+ Iterates over each possible combination of single items
104
+ from each sub-list. For example:
105
+
106
+ combinations([[1,2],[3,4]] -> [1,3], [1,4], [2,3], [2,4] in that order.
107
+
108
+
109
+ initialList - list of lists to derive combinations from.
110
+ """
111
+ if not initialList:
112
+ return
113
+ for result in _combinations(initialList[0], initialList[1:]):
114
+ yield result
115
+
116
+
117
+ def pairwiseCombinations(initialList):
118
+ """
119
+ Creates the minimum set of combinations that will make available
120
+ every possible pair available.
121
+ """
122
+ r = [len(x) for x in initialList]
123
+ m = min(r)
124
+ M = max(r)
125
+ n = len(initialList)
126
+
127
+ R = set()
128
+
129
+ for i in range(m):
130
+ t = [initialList[x][i] for x in range(n)]
131
+ R.add(tuple(t))
132
+
133
+ for i in range(m,M):
134
+ t = [initialList[x][min(r[x]-1,i)] for x in range(n)]
135
+ R.add(tuple(t))
136
+
137
+ for i in range(m):
138
+ for j in range(n):
139
+ for k in range(i+1,r[j]):
140
+ prejth = [initialList[x][i] for x in range(j)]
141
+
142
+ jth = initialList[j][k]
143
+
144
+ postjth = [initialList[x][i] for x in range(j+1, n)]
145
+
146
+ t = prejth + [jth] + postjth
147
+ R.add(tuple(t))
148
+
149
+ for i in range(m,M):
150
+ for j in range(n):
151
+ if r[i] < i:
152
+ continue
153
+ for k in range(i+1,r[j]):
154
+ prejth = [initialList[x][min(r[x]-1,i)] for x in range(j)]
155
+
156
+ jth = initialList[j][k]
157
+
158
+ postjth = [initialList[x][min(r[x]-1,i)] for x in range(j+1, n)]
159
+
160
+ t = prejth + [jth] + postjth
161
+ R.add(tuple(t))
162
+
163
+ return R
164
+
165
+ def get_residue_interaction_energy(residue1, residue2):
166
+ """
167
+ Returns to total energy of every atom pair between the two residues.
168
+
169
+ Uses Optimize.getPairEnergy and it's donor/accepter model
170
+ to determine energy.
171
+
172
+ residue1 - "donor" residue
173
+ residue2 - "acceptor" residue
174
+
175
+ THE RESULTS OF THIS FUNCTION ARE NOT SYMMETRIC. Swapping
176
+ residue1 and residue2 will not always produce the same result.
177
+ """
178
+ energy = 0.0
179
+ for pair in product(residue1.getAtoms(), residue2.getAtoms()):
180
+ energy += Optimize.getPairEnergy(pair[0], pair[1])
181
+
182
+ return energy
183
+
184
+ def save_residue_interaction_energies(residues, output):
185
+ """
186
+ Writes out the residue interaction energy for each possible
187
+ residue pair in the protein.
188
+ """
189
+ residuepairs = permutations(residues, 2)
190
+
191
+ for pair in residuepairs:
192
+ energy = get_residue_interaction_energy(pair[0], pair[1])
193
+ pairText = str(pair[0]) + ' ' + str(pair[1])
194
+ if pairText in _pairEnergyResults:
195
+
196
+ oldEnergy = _pairEnergyResults[pairText]
197
+ energyDiff = oldEnergy - energy
198
+ if abs(energyDiff) > PAIR_ENERGY_EPSILON:
199
+ txt = '#%s re-tested' % pairText
200
+ txt += ' with a difference of %s' % repr(energyDiff)
201
+ if (energy != 0):
202
+ txt += ' and a reference of %s' % repr(energyDiff/energy)
203
+ else:
204
+ txt += ' and the previous energy was 0'
205
+ txt += '\n'
206
+
207
+ output.write(txt)
208
+
209
+ continue
210
+
211
+ _pairEnergyResults[pairText] = energy
212
+
213
+
214
+ def get_residue_titration_sets(residues):
215
+ """
216
+ Returns all possible titration states for each residue as a list of lists.
217
+ """
218
+ result = []
219
+ for residue in residues:
220
+ result.append(_titrationSetsMap.get(residue.name, (residue.name,)))
221
+
222
+ return result
223
+
224
+ def process_residue_set(residueSet, routines, output, clean = False,
225
+ neutraln = False,
226
+ neutralc = False,
227
+ ligand = None,
228
+ assign_only = False,
229
+ chain = False,
230
+ debump = True,
231
+ opt = True):
232
+ routines.write(str(residueSet)+'\n')
233
+
234
+ routines.removeHydrogens()
235
+
236
+ for newResidueName, oldResidue, index in izip(residueSet, routines.protein.getResidues(), count()):
237
+ if newResidueName is None:
238
+ continue
239
+
240
+ chain = routines.protein.chainmap[oldResidue.chainID]
241
+ chainIndex = chain.residues.index(oldResidue)
242
+ residueAtoms = oldResidue.atoms
243
+
244
+ #Create the replacement residue
245
+ newResidue = routines.protein.createResidue(residueAtoms, newResidueName)
246
+
247
+ #Make sure our names are cleaned up for output.
248
+ newResidue.renameResidue(newResidueName)
249
+
250
+ #Drop it in
251
+ routines.protein.residues[index] = newResidue
252
+ chain.residues[chainIndex] = newResidue
253
+
254
+ #Run the meaty bits of PDB2PQR
255
+ routines.setTermini(neutraln, neutralc)
256
+ routines.updateBonds()
257
+
258
+ if not clean and not assign_only:
259
+ routines.updateSSbridges()
260
+
261
+ if debump:
262
+ routines.debumpProtein()
263
+
264
+ routines.addHydrogens()
265
+
266
+ hydRoutines = hydrogenRoutines(routines)
267
+
268
+ if debump:
269
+ routines.debumpProtein()
270
+
271
+ if opt:
272
+ hydRoutines.setOptimizeableHydrogens()
273
+ hydRoutines.initializeFullOptimization()
274
+ hydRoutines.optimizeHydrogens()
275
+ else:
276
+ hydRoutines.initializeWaterOptimization()
277
+ hydRoutines.optimizeHydrogens()
278
+
279
+ # Special for GLH/ASH, since both conformations were added
280
+ hydRoutines.cleanup()
281
+
282
+ save_residue_interaction_energies(routines.protein.getResidues(), output)
283
+
284
+
285
+ def write_all_residue_interaction_energies_combinations(routines, output, options, all_residue_combinations=False):
286
+ """
287
+ For every titration state combination of residue output the
288
+ interaction energy for all possible residue pairs.
289
+ """
290
+ residueNamesList = get_residue_titration_sets(routines.protein.getResidues())
291
+
292
+ routines.write("Testing the following combinations\n")
293
+ namelist = [r.name for r in routines.protein.getResidues()]
294
+ combinationsData = izip(namelist, residueNamesList)
295
+ for thing in combinationsData:
296
+ routines.write(str(thing)+'\n')
297
+
298
+ if all_residue_combinations:
299
+ combinationGenerator = combinations(residueNamesList)
300
+ else:
301
+ combinationGenerator = pairwiseCombinations(residueNamesList)
302
+
303
+ count = 0
304
+ for residueSet in combinationGenerator:
305
+ count += 1
306
+ process_residue_set(residueSet, routines, output,
307
+ clean = options.clean,
308
+ neutraln = options.neutraln,
309
+ neutralc = options.neutralc,
310
+ ligand = options.ligand,
311
+ assign_only = options.assign_only,
312
+ chain = options.chain,
313
+ debump = options.debump,
314
+ opt = options.opt)
315
+
316
+ for resultKey in sorted(_pairEnergyResults.iterkeys()):
317
+ output.write(resultKey + ' ' + str(_pairEnergyResults[resultKey]) + '\n')
318
+
319
+ routines.write(str(count)+' residue combinations tried\n')
320
+
321
+ def create_resinter_output(routines, outfile, options,
322
+ residue_combinations=False,
323
+ all_residue_combinations=False):
324
+ """
325
+ Output the interaction energy between each possible residue pair.
326
+ """
327
+ routines.write("Printing residue interaction energies...\n")
328
+
329
+ output = extensions.extOutputHelper(routines, outfile)
330
+
331
+ if residue_combinations or all_residue_combinations:
332
+ write_all_residue_interaction_energies_combinations(routines, output, options,
333
+ all_residue_combinations=all_residue_combinations)
334
+ else:
335
+ save_residue_interaction_energies(routines.protein.getResidues(), output)
336
+
337
+
338
+ def run_extension(routines, outroot, options):
339
+ outname = outroot + ".resinter"
340
+ with open(outname, "w") as outfile:
341
+ create_resinter_output(routines, outfile, options,
342
+ residue_combinations=options.residue_combinations,
343
+ all_residue_combinations=options.all_residue_combinations)
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/salt.py ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Saltbridge extension
3
+
4
+ Find all salt bridges as determined by the cutoff distance below.
5
+ Uses PDB2PQR to determine atom identities and distances, and write
6
+ out all located salt bridges to stdout.
7
+
8
+ NOTE: A bond may be labeled BOTH hbond and salt-bridge if you use both
9
+ options in one pdb2pqr run. Look out for double counting.
10
+
11
+ NOTE: This extension currently does not support salt bridges with chain termini.
12
+
13
+ Author: Mike Bradley (heavily copied from Todd Dolinsky's hbond extension)
14
+ """
15
+
16
+ __date__ = "25 August 2006"
17
+ __author__ = "Mike Bradley"
18
+
19
+ from src.utilities import distance
20
+ from src.routines import Cells
21
+
22
+ DIST_CUTOFF = 4.0 # maximum cation to anion atom distance in angstroms
23
+
24
+ def usage():
25
+ return 'Print a list of salt bridges to {output-path}.salt'
26
+
27
+ def run_extension(routines, outroot, options):
28
+ """
29
+ Print a list of salt bridges.
30
+
31
+ Parameters
32
+ routines: A link to the routines object
33
+ outroot: The root of the output name
34
+ options: options object
35
+ """
36
+ outname = outroot + ".salt"
37
+ outfile = open(outname, "w")
38
+
39
+ routines.write("Printing salt bridge list...\n")
40
+
41
+ # Define the potential salt bridge atoms here (the current lists are for the AMBER
42
+ # forcefield and are not necessarily exhaustive).
43
+ posresList = ["LYS","ARG","HIP"]
44
+ negresList = ["GLU","ASP","CYM"]
45
+ posatomList = ["NE","NH1","NH2","NZ","ND1","NE2",]
46
+ negatomList = ["SG","OE1","OE2","OD1","OD2"]
47
+
48
+ # Initialize - set nearby cells
49
+ # The cell size adds one for the salt bridge distance, and rounds up
50
+
51
+ cellsize = int(DIST_CUTOFF + 1.0 + 1.0)
52
+ protein = routines.protein
53
+ routines.cells = Cells(cellsize)
54
+ routines.cells.assignCells(protein)
55
+
56
+ # Loop over all the atoms
57
+ for cation in protein.getAtoms():
58
+ # check that we've found a cation
59
+ if cation.residue.name == "NMET":
60
+ print "YES NMET"
61
+ if cation.residue.name not in posresList:
62
+ continue
63
+ elif cation.name not in posatomList:
64
+ continue
65
+ # For each cation, grab all potential anions in nearby cells
66
+ closeatoms = routines.cells.getNearCells(cation)
67
+ for anion in closeatoms:
68
+ if cation.residue.name == anion.residue.name:
69
+ continue
70
+ if anion.residue.name not in negresList:
71
+ continue
72
+ elif anion.name not in negatomList:
73
+ continue
74
+ # Do distance check
75
+ dist = distance(cation.getCoords(), anion.getCoords())
76
+ if dist > DIST_CUTOFF:
77
+ continue
78
+ #routines.write("Cation: %s %s\tAnion: %s %s\tsaltdist: %.2f\n" % \
79
+ # (cation.residue, cation.name, anion.residue, anion.name, dist))
80
+ outfile.write("Cation: %s %s\tAnion: %s %s\tsaltdist: %.2f\n" % \
81
+ (cation.residue, cation.name, anion.residue, anion.name, dist))
82
+ #routines.write("\n")
83
+ outfile.close()
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/summary.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Summary extension
3
+
4
+ Print protein summary file.
5
+ Currently prints a list of all residue in protein.
6
+ """
7
+
8
+ __date__ = "21 October 2011"
9
+ __author__ = "Kyle Monson"
10
+
11
+ import extensions
12
+
13
+ def usage():
14
+ """
15
+ Returns usage text for summary.
16
+ """
17
+ return 'Print protein summary information to {output-path}.summary.'
18
+
19
+ def create_summary_output(routines, outfile):
20
+ """
21
+ Output the interaction energy between each possible residue pair.
22
+ """
23
+ routines.write("Printing protein summary...\n")
24
+
25
+ output = extensions.extOutputHelper(routines, outfile)
26
+
27
+ output.write(routines.protein.getSummary() + '\n')
28
+
29
+ for residue in routines.protein.getResidues():
30
+ output.write(str(residue)+'\n')
31
+
32
+ def run_extension(routines, outroot, options):
33
+ outname = outroot + ".summary"
34
+ with open(outname, "w") as outfile:
35
+ create_summary_output(routines, outfile)
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/extensions/template ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Extensions Template
3
+
4
+ A template for creating new post-processing scripts. Please see the
5
+ PDB2PQR Programmer Guide for more information.
6
+
7
+ Author: Todd Dolinsky
8
+ """
9
+
10
+ __date__ = "17 February 2006" # Date
11
+ __author__ = "Todd Dolinsky" # Author
12
+
13
+ from src.utilities import * # Functions from utilities.py
14
+ from src.routines import * # Functions from routines.py
15
+
16
+ def usage():
17
+ """
18
+ A small function that will be added to the overall PDB2PQR
19
+ usage. Note that the root of the file name (in this case template.py)
20
+ becomes the command line option.
21
+
22
+ ex. chi.py will add the --chi command line option.
23
+
24
+ Returns a string describing the usage for this function.
25
+ This will be used for help text for command line option for this function.
26
+ Defining this function is optional.
27
+ """
28
+ str = "Put usage here"
29
+ return str
30
+
31
+ def addExtensionOptions(extensionGroup):
32
+ """
33
+ Add options specific to this extension to the option parser.
34
+ This function is optional.
35
+
36
+ extensionGroup: A link to the OptionParser group object for extension
37
+ options. See the Python OptionParser documentation.
38
+
39
+ Option names must not conflict with other option names.
40
+ """
41
+ extensionGroup.add_option('--Ni', dest='Ni', action='store_true', default=False,
42
+ help='Include N atoms in template output')
43
+ extensionGroup.add_option('--Ox', dest='Ox', action='store_true', default=False,
44
+ help='Include O atoms in template output')
45
+
46
+ def run_extension(routines, outroot, options):
47
+ """
48
+ The main function. This will be called after all other PDB2PQR
49
+ activity has been completed. There are two useful parameters
50
+ that must be passed into the function.
51
+ This functions is required.
52
+
53
+ Parameters
54
+ routines: A link to the routines object The routines object
55
+ contains both protein (routines.protein) and links
56
+ to the majority of functions necessary to use the
57
+ PDB2PQR API.
58
+ outroot: A string containing the root of the output name. If
59
+ you want to return information to stdout this can be
60
+ ignored (although it must still be present) - otherwise
61
+ this can be used to output the desired data to a file.
62
+ The root contains whatever the desired PQR file name is
63
+ before the period, so "out.pqr" will have "out", and
64
+ "example" will just return "example". For other
65
+ extension scripts we have appended the function name
66
+ to the outroot.
67
+ options: A options parser like class containing additional options
68
+ created for this extension by the optional addExtensionOptions
69
+ function.
70
+ """
71
+
72
+ outname = outroot + ".template"
73
+ file = open(outname, "w")
74
+
75
+ protein = routines.protein
76
+
77
+ # For example, let's write all the CA atoms in the protein to the file
78
+
79
+ for atom in protein.getAtoms():
80
+ if atom.name == "CA": file.write(atom)
81
+
82
+ file.close()
83
+
84
+
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/include/python2.7/pyconfig.h ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #if defined(__linux__)
2
+ # if defined(__x86_64__) && defined(__LP64__)
3
+ # include <x86_64-linux-gnu/python2.7/pyconfig.h>
4
+ # elif defined(__x86_64__) && defined(__ILP32__)
5
+ # include <x86_64-linux-gnux32/python2.7/pyconfig.h>
6
+ # elif defined(__i386__)
7
+ # include <i386-linux-gnu/python2.7/pyconfig.h>
8
+ # elif defined(__aarch64__) && defined(__AARCH64EL__)
9
+ # include <aarch64-linux-gnu/python2.7/pyconfig.h>
10
+ # elif defined(__alpha__)
11
+ # include <alpha-linux-gnu/python2.7/pyconfig.h>
12
+ # elif defined(__ARM_EABI__) && defined(__ARM_PCS_VFP)
13
+ # include <arm-linux-gnueabihf/python2.7/pyconfig.h>
14
+ # elif defined(__ARM_EABI__) && !defined(__ARM_PCS_VFP)
15
+ # include <arm-linux-gnueabi/python2.7/pyconfig.h>
16
+ # elif defined(__hppa__)
17
+ # include <hppa-linux-gnu/python2.7/pyconfig.h>
18
+ # elif defined(__ia64__)
19
+ # include <ia64-linux-gnu/python2.7/pyconfig.h>
20
+ # elif defined(__m68k__) && !defined(__mcoldfire__)
21
+ # include <m68k-linux-gnu/python2.7/pyconfig.h>
22
+ # elif defined(__mips_hard_float) && defined(_MIPSEL)
23
+ # if _MIPS_SIM == _ABIO32
24
+ # include <mipsel-linux-gnu/python2.7/pyconfig.h>
25
+ # elif _MIPS_SIM == _ABIN32
26
+ # include <mips64el-linux-gnuabin32/python2.7/pyconfig.h>
27
+ # elif _MIPS_SIM == _ABI64
28
+ # include <mips64el-linux-gnuabi64/python2.7/pyconfig.h>
29
+ # else
30
+ # error unknown multiarch location for pyconfig.h
31
+ # endif
32
+ # elif defined(__mips_hard_float)
33
+ # if _MIPS_SIM == _ABIO32
34
+ # include <mips-linux-gnu/python2.7/pyconfig.h>
35
+ # elif _MIPS_SIM == _ABIN32
36
+ # include <mips64-linux-gnuabin32/python2.7/pyconfig.h>
37
+ # elif _MIPS_SIM == _ABI64
38
+ # include <mips64-linux-gnuabi64/python2.7/pyconfig.h>
39
+ # else
40
+ # error unknown multiarch location for pyconfig.h
41
+ # endif
42
+ # elif defined(__or1k__)
43
+ # include <or1k-linux-gnu/python2.7/pyconfig.h>
44
+ # elif defined(__powerpc__) && defined(__SPE__)
45
+ # include <powerpc-linux-gnuspe/python2.7/pyconfig.h>
46
+ # elif defined(__powerpc64__)
47
+ # if defined(__LITTLE_ENDIAN__)
48
+ # include <powerpc64le-linux-gnu/python2.7/pyconfig.h>
49
+ # else
50
+ # include <powerpc64-linux-gnu/python2.7/pyconfig.h>
51
+ # endif
52
+ # elif defined(__powerpc__)
53
+ # include <powerpc-linux-gnu/python2.7/pyconfig.h>
54
+ # elif defined(__s390x__)
55
+ # include <s390x-linux-gnu/python2.7/pyconfig.h>
56
+ # elif defined(__s390__)
57
+ # include <s390-linux-gnu/python2.7/pyconfig.h>
58
+ # elif defined(__sh__) && defined(__LITTLE_ENDIAN__)
59
+ # include <sh4-linux-gnu/python2.7/pyconfig.h>
60
+ # elif defined(__sparc__) && defined(__arch64__)
61
+ # include <sparc64-linux-gnu/python2.7/pyconfig.h>
62
+ # elif defined(__sparc__)
63
+ # include <sparc-linux-gnu/python2.7/pyconfig.h>
64
+ # else
65
+ # error unknown multiarch location for pyconfig.h
66
+ # endif
67
+ #elif defined(__FreeBSD_kernel__)
68
+ # if defined(__LP64__)
69
+ # include <x86_64-kfreebsd-gnu/python2.7/pyconfig.h>
70
+ # elif defined(__i386__)
71
+ # include <i386-kfreebsd-gnu/python2.7/pyconfig.h>
72
+ # else
73
+ # error unknown multiarch location for pyconfig.h
74
+ # endif
75
+ #elif defined(__gnu_hurd__)
76
+ # include <i386-gnu/python2.7/pyconfig.h>
77
+ #else
78
+ # error unknown multiarch location for pyconfig.h
79
+ #endif
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib/python2.7/config-x86_64-linux-gnu/Makefile ADDED
@@ -0,0 +1,1499 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Generated automatically from Makefile.pre by makesetup.
2
+ # Top-level Makefile for Python
3
+ #
4
+ # As distributed, this file is called Makefile.pre.in; it is processed
5
+ # into the real Makefile by running the script ./configure, which
6
+ # replaces things like @spam@ with values appropriate for your system.
7
+ # This means that if you edit Makefile, your changes get lost the next
8
+ # time you run the configure script. Ideally, you can do:
9
+ #
10
+ # ./configure
11
+ # make
12
+ # make test
13
+ # make install
14
+ #
15
+ # If you have a previous version of Python installed that you don't
16
+ # want to overwrite, you can use "make altinstall" instead of "make
17
+ # install". Refer to the "Installing" section in the README file for
18
+ # additional details.
19
+ #
20
+ # See also the section "Build instructions" in the README file.
21
+
22
+ # === Variables set by makesetup ===
23
+
24
+ MODOBJS= Modules/threadmodule.o Modules/signalmodule.o Modules/arraymodule.o Modules/cmathmodule.o Modules/mathmodule.o Modules/_math.o Modules/_struct.o Modules/timemodule.o Modules/operator.o Modules/_randommodule.o Modules/_collectionsmodule.o Modules/_heapqmodule.o Modules/itertoolsmodule.o Modules/stropmodule.o Modules/_functoolsmodule.o Modules/_bisectmodule.o Modules/unicodedata.o Modules/_localemodule.o Modules/bufferedio.o Modules/bytesio.o Modules/fileio.o Modules/iobase.o Modules/_iomodule.o Modules/stringio.o Modules/textio.o Modules/fcntlmodule.o Modules/spwdmodule.o Modules/grpmodule.o Modules/selectmodule.o Modules/socketmodule.o Modules/timemodule.o Modules/md5module.o Modules/md5.o Modules/shamodule.o Modules/sha256module.o Modules/sha512module.o Modules/syslogmodule.o Modules/binascii.o Modules/cStringIO.o Modules/cPickle.o Modules/zlibmodule.o Modules/posixmodule.o Modules/errnomodule.o Modules/pwdmodule.o Modules/_sre.o Modules/_codecsmodule.o Modules/_weakref.o Modules/zipimport.o Modules/symtablemodule.o Modules/xxsubtype.o
25
+ MODLIBS= $(LOCALMODLIBS) $(BASEMODLIBS)
26
+
27
+ # === Variables set by configure
28
+ VERSION= 2.7
29
+ srcdir= ..
30
+ VPATH= ..
31
+ abs_srcdir= /build/buildd/python2.7-2.7.6/build-shared/..
32
+ abs_builddir= /build/buildd/python2.7-2.7.6/build-shared
33
+ build= x86_64-unknown-linux-gnu
34
+ host= x86_64-unknown-linux-gnu
35
+
36
+ CC= x86_64-linux-gnu-gcc -pthread
37
+ CXX= c++ -pthread
38
+ MAINCC= $(CC)
39
+ LINKCC= $(PURIFY) $(MAINCC)
40
+ AR= ar
41
+ RANLIB= ranlib
42
+ SVNVERSION= echo Unversioned directory
43
+ HGVERSION=
44
+ HGTAG=
45
+ HGBRANCH=
46
+
47
+ GNULD= yes
48
+
49
+ # Shell used by make (some versions default to the login shell, which is bad)
50
+ SHELL= /bin/sh
51
+
52
+ # Use this to make a link between python$(VERSION) and python in $(BINDIR)
53
+ LN= ln
54
+
55
+ # Portable install script (configure doesn't always guess right)
56
+ INSTALL= /usr/bin/install -c
57
+ INSTALL_PROGRAM=${INSTALL}
58
+ INSTALL_SCRIPT= ${INSTALL}
59
+ INSTALL_DATA= ${INSTALL} -m 644
60
+ # Shared libraries must be installed with executable mode on some systems;
61
+ # rather than figuring out exactly which, we always give them executable mode.
62
+ # Also, making them read-only seems to be a good idea...
63
+ INSTALL_SHARED= ${INSTALL} -m 555
64
+
65
+ MKDIR_P= /bin/mkdir -p
66
+
67
+ MAKESETUP= $(srcdir)/Modules/makesetup
68
+
69
+ # Compiler options
70
+ OPT= -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes
71
+ BASECFLAGS= -fno-strict-aliasing
72
+ CONFIGURE_CFLAGS= -D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security
73
+ CONFIGURE_CPPFLAGS=
74
+ CONFIGURE_LDFLAGS= -Wl,-Bsymbolic-functions -Wl,-z,relro
75
+ # Avoid assigning CFLAGS, LDFLAGS, etc. so users can use them on the
76
+ # command line to append to these values without stomping the pre-set
77
+ # values.
78
+ PY_CFLAGS= $(BASECFLAGS) $(OPT) $(CONFIGURE_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS)
79
+ # Both CPPFLAGS and LDFLAGS need to contain the shell's value for setup.py to
80
+ # be able to build extension modules using the directories specified in the
81
+ # environment variables
82
+ PY_CPPFLAGS= -I. -IInclude -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) $(CPPFLAGS)
83
+ PY_LDFLAGS= $(CONFIGURE_LDFLAGS) $(LDFLAGS)
84
+ LDLAST=
85
+ SGI_ABI=
86
+ CCSHARED= -fPIC
87
+ LINKFORSHARED= -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions
88
+ ARFLAGS= rc
89
+ # Extra C flags added for building the interpreter object files.
90
+ CFLAGSFORSHARED=$(CCSHARED)
91
+ # C flags used for building the interpreter object files
92
+ PY_CORE_CFLAGS= $(PY_CFLAGS) $(PY_CPPFLAGS) $(CFLAGSFORSHARED) -DPy_BUILD_CORE
93
+
94
+
95
+ # Machine-dependent subdirectories
96
+ MACHDEP= linux2
97
+
98
+ # Multiarch directory (may be empty)
99
+ MULTIARCH= x86_64-linux-gnu
100
+
101
+ # Multiarch directory (may be empty)
102
+ MULTIARCH= x86_64-linux-gnu
103
+
104
+ # Install prefix for architecture-independent files
105
+ prefix= /usr
106
+
107
+ # Install prefix for architecture-dependent files
108
+ exec_prefix= ${prefix}
109
+
110
+ # Install prefix for data files
111
+ datarootdir= ${prefix}/share
112
+
113
+ # Expanded directories
114
+ BINDIR= ${exec_prefix}/bin
115
+ LIBDIR= ${exec_prefix}/lib
116
+ MANDIR= ${datarootdir}/man
117
+ INCLUDEDIR= ${prefix}/include
118
+ CONFINCLUDEDIR= $(exec_prefix)/include
119
+ SCRIPTDIR= $(prefix)/lib
120
+
121
+ # Detailed destination directories
122
+ BINLIBDEST= $(LIBDIR)/python$(VERSION)
123
+ LIBDEST= $(SCRIPTDIR)/python$(VERSION)
124
+ INCLUDEPY= $(INCLUDEDIR)/python$(VERSION)$(DEBUG_EXT)
125
+ CONFINCLUDEPY= $(CONFINCLUDEDIR)/python$(VERSION)$(DEBUG_EXT)
126
+ LIBP= $(LIBDIR)/python$(VERSION)
127
+
128
+ # Symbols used for using shared libraries
129
+ SO= .so
130
+ LDSHARED= $(CC) -shared -Wl,-O1 -Wl,-Bsymbolic-functions $(PY_LDFLAGS)
131
+ BLDSHARED= $(CC) -shared -Wl,-O1 -Wl,-Bsymbolic-functions $(PY_LDFLAGS) $(PY_CFLAGS)
132
+ LDCXXSHARED= $(CXX) -shared -Wl,-O1 -Wl,-Bsymbolic-functions
133
+ DESTSHARED= $(BINLIBDEST)/lib-dynload
134
+
135
+ # Executable suffix (.exe on Windows and Mac OS X)
136
+ EXE=
137
+ BUILDEXE=
138
+
139
+ DEBUG_EXT=
140
+
141
+ # Short name and location for Mac OS X Python framework
142
+ UNIVERSALSDK=
143
+ PYTHONFRAMEWORK=
144
+ PYTHONFRAMEWORKDIR= no-framework
145
+ PYTHONFRAMEWORKPREFIX=
146
+ PYTHONFRAMEWORKINSTALLDIR=
147
+ # Deployment target selected during configure, to be checked
148
+ # by distutils. The export statement is needed to ensure that the
149
+ # deployment target is active during build.
150
+ MACOSX_DEPLOYMENT_TARGET=
151
+ #export MACOSX_DEPLOYMENT_TARGET
152
+
153
+ # Options to enable prebinding (for fast startup prior to Mac OS X 10.3)
154
+ OTHER_LIBTOOL_OPT=
155
+
156
+ # Environment to run shared python without installed libraries
157
+ RUNSHARED=
158
+
159
+ # Modes for directories, executables and data files created by the
160
+ # install process. Default to user-only-writable for all file types.
161
+ DIRMODE= 755
162
+ EXEMODE= 755
163
+ FILEMODE= 644
164
+
165
+ # configure script arguments
166
+ CONFIG_ARGS= '--enable-shared' '--prefix=/usr' '--enable-ipv6' '--enable-unicode=ucs4' '--with-dbmliborder=bdb:gdbm' '--with-system-expat' '--with-system-ffi' '--with-fpectl' 'CC=x86_64-linux-gnu-gcc' 'CFLAGS=-D_FORTIFY_SOURCE=2 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security ' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro'
167
+
168
+
169
+ # Subdirectories with code
170
+ SRCDIRS= Parser Grammar Objects Python Modules Mac
171
+
172
+ # Other subdirectories
173
+ SUBDIRSTOO= Include Lib Misc Demo
174
+
175
+ # Files and directories to be distributed
176
+ CONFIGFILES= configure configure.ac acconfig.h pyconfig.h.in Makefile.pre.in
177
+ DISTFILES= README ChangeLog $(CONFIGFILES)
178
+ DISTDIRS= $(SUBDIRS) $(SUBDIRSTOO) Ext-dummy
179
+ DIST= $(DISTFILES) $(DISTDIRS)
180
+
181
+
182
+ LIBRARY= libpython$(VERSION)$(DEBUG_EXT).a
183
+ LDLIBRARY= libpython$(VERSION)$(DEBUG_EXT).so
184
+ BLDLIBRARY= -lpython$(VERSION)$(DEBUG_EXT)
185
+ DLLLIBRARY=
186
+ LDLIBRARYDIR=
187
+ INSTSONAME= libpython$(VERSION)$(DEBUG_EXT).so.1.0
188
+
189
+
190
+ LIBS= -lpthread -ldl -lutil
191
+ LIBM= -lm
192
+ LIBC=
193
+ SYSLIBS= $(LIBM) $(LIBC)
194
+ SHLIBS= $(LIBS)
195
+
196
+ THREADOBJ= Python/thread.o
197
+ DLINCLDIR= .
198
+ DYNLOADFILE= dynload_shlib.o
199
+ MACHDEP_OBJS=
200
+ LIBOBJDIR= Python/
201
+ LIBOBJS=
202
+ UNICODE_OBJS= Objects/unicodeobject.o Objects/unicodectype.o
203
+
204
+ PYTHON= python$(EXE)
205
+ BUILDPYTHON= python$(BUILDEXE)
206
+
207
+ PYTHON_FOR_BUILD=./$(BUILDPYTHON) -E
208
+ _PYTHON_HOST_PLATFORM=
209
+ HOST_GNU_TYPE= x86_64-unknown-linux-gnu
210
+
211
+ # Tcl and Tk config info from --with-tcltk-includes and -libs options
212
+ TCLTK_INCLUDES=
213
+ TCLTK_LIBS=
214
+
215
+ # The task to run while instrument when building the profile-opt target
216
+ PROFILE_TASK= $(srcdir)/Tools/pybench/pybench.py -n 2 --with-gc --with-syscheck
217
+ #PROFILE_TASK= $(srcdir)/Lib/test/regrtest.py
218
+
219
+ # === Definitions added by makesetup ===
220
+
221
+ LOCALMODLIBS= -L$(exec_prefix)/lib -lz
222
+ BASEMODLIBS=
223
+ GLHACK=-Dclear=__GLclear
224
+ PYTHONPATH=$(COREPYTHONPATH)
225
+ COREPYTHONPATH=$(DESTPATH)$(SITEPATH)$(TESTPATH)$(MACHDEPPATH)$(EXTRAMACHDEPPATH)$(TKPATH)$(OLDPATH)
226
+ OLDPATH=:lib-old
227
+ TKPATH=:lib-tk
228
+ EXTRAMACHDEPPATH=
229
+ MACHDEPPATH=:plat-$(MULTIARCH)
230
+ TESTPATH=
231
+ SITEPATH=
232
+ DESTPATH=
233
+ MACHDESTLIB=$(BINLIBDEST)
234
+ DESTLIB=$(LIBDEST)
235
+
236
+
237
+
238
+ ##########################################################################
239
+ # Modules
240
+ MODULE_OBJS= \
241
+ Modules/config.o \
242
+ Modules/getpath.o \
243
+ Modules/main.o \
244
+ Modules/gcmodule.o
245
+
246
+ # Used of signalmodule.o is not available
247
+ SIGNAL_OBJS=
248
+
249
+
250
+ ##########################################################################
251
+ # Grammar
252
+ GRAMMAR_H= Include/graminit.h
253
+ GRAMMAR_C= Python/graminit.c
254
+ GRAMMAR_INPUT= $(srcdir)/Grammar/Grammar
255
+
256
+
257
+ LIBFFI_INCLUDEDIR=
258
+
259
+ ##########################################################################
260
+ # Parser
261
+ PGEN= Parser/pgen$(EXE)
262
+
263
+ PSRCS= \
264
+ Parser/acceler.c \
265
+ Parser/grammar1.c \
266
+ Parser/listnode.c \
267
+ Parser/node.c \
268
+ Parser/parser.c \
269
+ Parser/parsetok.c \
270
+ Parser/bitset.c \
271
+ Parser/metagrammar.c \
272
+ Parser/firstsets.c \
273
+ Parser/grammar.c \
274
+ Parser/pgen.c
275
+
276
+ POBJS= \
277
+ Parser/acceler.o \
278
+ Parser/grammar1.o \
279
+ Parser/listnode.o \
280
+ Parser/node.o \
281
+ Parser/parser.o \
282
+ Parser/parsetok.o \
283
+ Parser/bitset.o \
284
+ Parser/metagrammar.o \
285
+ Parser/firstsets.o \
286
+ Parser/grammar.o \
287
+ Parser/pgen.o
288
+
289
+ PARSER_OBJS= $(POBJS) Parser/myreadline.o Parser/tokenizer.o
290
+
291
+ PGSRCS= \
292
+ Objects/obmalloc.c \
293
+ Python/mysnprintf.c \
294
+ Python/pyctype.c \
295
+ Parser/tokenizer_pgen.c \
296
+ Parser/printgrammar.c \
297
+ Parser/pgenmain.c
298
+
299
+ PGOBJS= \
300
+ Objects/obmalloc.o \
301
+ Python/mysnprintf.o \
302
+ Python/pyctype.o \
303
+ Parser/tokenizer_pgen.o \
304
+ Parser/printgrammar.o \
305
+ Parser/pgenmain.o
306
+
307
+ PARSER_HEADERS= \
308
+ Parser/parser.h \
309
+ Parser/tokenizer.h
310
+
311
+ PGENSRCS= $(PSRCS) $(PGSRCS)
312
+ PGENOBJS= $(POBJS) $(PGOBJS)
313
+
314
+ ##########################################################################
315
+ # AST
316
+ AST_H_DIR= Include
317
+ AST_H= $(AST_H_DIR)/Python-ast.h
318
+ AST_C_DIR= Python
319
+ AST_C= $(AST_C_DIR)/Python-ast.c
320
+ AST_ASDL= $(srcdir)/Parser/Python.asdl
321
+
322
+ ASDLGEN_FILES= $(srcdir)/Parser/asdl.py $(srcdir)/Parser/asdl_c.py
323
+ # XXX Note that a build now requires Python exist before the build starts
324
+ ASDLGEN= $(srcdir)/Parser/asdl_c.py
325
+
326
+ ##########################################################################
327
+ # Python
328
+ PYTHON_OBJS= \
329
+ Python/_warnings.o \
330
+ Python/Python-ast.o \
331
+ Python/asdl.o \
332
+ Python/ast.o \
333
+ Python/bltinmodule.o \
334
+ Python/ceval.o \
335
+ Python/compile.o \
336
+ Python/codecs.o \
337
+ Python/errors.o \
338
+ Python/frozen.o \
339
+ Python/frozenmain.o \
340
+ Python/future.o \
341
+ Python/getargs.o \
342
+ Python/getcompiler.o \
343
+ Python/getcopyright.o \
344
+ Python/getplatform.o \
345
+ Python/getversion.o \
346
+ Python/graminit.o \
347
+ Python/import.o \
348
+ Python/importdl.o \
349
+ Python/marshal.o \
350
+ Python/modsupport.o \
351
+ Python/mystrtoul.o \
352
+ Python/mysnprintf.o \
353
+ Python/peephole.o \
354
+ Python/pyarena.o \
355
+ Python/pyctype.o \
356
+ Python/pyfpe.o \
357
+ Python/pymath.o \
358
+ Python/pystate.o \
359
+ Python/pythonrun.o \
360
+ Python/random.o \
361
+ Python/structmember.o \
362
+ Python/symtable.o \
363
+ Python/sysmodule.o \
364
+ Python/traceback.o \
365
+ Python/getopt.o \
366
+ Python/pystrcmp.o \
367
+ Python/pystrtod.o \
368
+ Python/dtoa.o \
369
+ Python/formatter_unicode.o \
370
+ Python/formatter_string.o \
371
+ Python/$(DYNLOADFILE) \
372
+ $(LIBOBJS) \
373
+ $(MACHDEP_OBJS) \
374
+ $(THREADOBJ)
375
+
376
+
377
+ ##########################################################################
378
+ # Objects
379
+ OBJECT_OBJS= \
380
+ Objects/abstract.o \
381
+ Objects/boolobject.o \
382
+ Objects/bufferobject.o \
383
+ Objects/bytes_methods.o \
384
+ Objects/bytearrayobject.o \
385
+ Objects/capsule.o \
386
+ Objects/cellobject.o \
387
+ Objects/classobject.o \
388
+ Objects/cobject.o \
389
+ Objects/codeobject.o \
390
+ Objects/complexobject.o \
391
+ Objects/descrobject.o \
392
+ Objects/enumobject.o \
393
+ Objects/exceptions.o \
394
+ Objects/genobject.o \
395
+ Objects/fileobject.o \
396
+ Objects/floatobject.o \
397
+ Objects/frameobject.o \
398
+ Objects/funcobject.o \
399
+ Objects/intobject.o \
400
+ Objects/iterobject.o \
401
+ Objects/listobject.o \
402
+ Objects/longobject.o \
403
+ Objects/dictobject.o \
404
+ Objects/memoryobject.o \
405
+ Objects/methodobject.o \
406
+ Objects/moduleobject.o \
407
+ Objects/object.o \
408
+ Objects/obmalloc.o \
409
+ Objects/rangeobject.o \
410
+ Objects/setobject.o \
411
+ Objects/sliceobject.o \
412
+ Objects/stringobject.o \
413
+ Objects/structseq.o \
414
+ Objects/tupleobject.o \
415
+ Objects/typeobject.o \
416
+ Objects/weakrefobject.o \
417
+ $(UNICODE_OBJS)
418
+
419
+
420
+ ##########################################################################
421
+ # objects that get linked into the Python library
422
+ LIBRARY_OBJS= \
423
+ Modules/getbuildinfo.o \
424
+ $(PARSER_OBJS) \
425
+ $(OBJECT_OBJS) \
426
+ $(PYTHON_OBJS) \
427
+ $(MODULE_OBJS) \
428
+ $(SIGNAL_OBJS) \
429
+ $(sort $(MODOBJS))
430
+
431
+ #########################################################################
432
+ # Rules
433
+
434
+ # Default target
435
+ all: build_all
436
+ build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks
437
+
438
+ # Compile a binary with gcc profile guided optimization.
439
+ profile-opt:
440
+ @echo "Building with support for profile generation:"
441
+ $(MAKE) clean
442
+ $(MAKE) build_all_generate_profile
443
+ @echo "Running benchmark to generate profile data:"
444
+ $(MAKE) profile-removal
445
+ $(MAKE) run_profile_task
446
+ @echo "Rebuilding with profile guided optimizations:"
447
+ $(MAKE) clean
448
+ $(MAKE) build_all_use_profile
449
+
450
+ build_all_generate_profile:
451
+ $(MAKE) all PY_CFLAGS="$(PY_CFLAGS) -fprofile-generate" LIBS="$(LIBS) -lgcov"
452
+
453
+ run_profile_task:
454
+ : # FIXME: can't run for a cross build
455
+ -./$(BUILDPYTHON) $(PROFILE_TASK)
456
+
457
+ build_all_use_profile:
458
+ $(MAKE) all PY_CFLAGS="$(PY_CFLAGS) -fprofile-use -fprofile-correction"
459
+
460
+ coverage:
461
+ @echo "Building with support for coverage checking:"
462
+ $(MAKE) clean
463
+ $(MAKE) all PY_CFLAGS="$(PY_CFLAGS) -O0 -pg -fprofile-arcs -ftest-coverage" LIBS="$(LIBS) -lgcov"
464
+
465
+
466
+ # Build the interpreter
467
+ $(BUILDPYTHON): Modules/python.o $(LIBRARY) $(LDLIBRARY)
468
+ $(LINKCC) $(PY_LDFLAGS) $(PY_CFLAGS) $(LINKFORSHARED) -o $@ \
469
+ Modules/python.o \
470
+ -Wl,--whole-archive $(BLDLIBRARY) -Wl,--no-whole-archive $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
471
+
472
+ platform: $(BUILDPYTHON) pybuilddir.txt
473
+ $(RUNSHARED) $(PYTHON_FOR_BUILD) -c 'import sys ; from sysconfig import get_platform ; print get_platform()+"-"+sys.version[0:3]' >platform
474
+
475
+ # Create build directory and generate the sysconfig build-time data there.
476
+ # pybuilddir.txt contains the name of the build dir and is used for
477
+ # sys.path fixup -- see Modules/getpath.c.
478
+ pybuilddir.txt: $(BUILDPYTHON)
479
+ $(RUNSHARED) $(PYTHON_FOR_BUILD) -S -m sysconfig --generate-posix-vars
480
+
481
+ # Build the shared modules
482
+ # Under GNU make, MAKEFLAGS are sorted and normalized; the 's' for
483
+ # -s, --silent or --quiet is always the first char.
484
+ # Under BSD make, MAKEFLAGS might be " -s -v x=y".
485
+ sharedmods: $(BUILDPYTHON) pybuilddir.txt
486
+ @case "$$MAKEFLAGS" in \
487
+ *\ -s*|s*) quiet="-q";; \
488
+ *) quiet="";; \
489
+ esac; \
490
+ $(RUNSHARED) CC='$(CC)' LDSHARED='$(BLDSHARED)' LDFLAGS='$(PY_LDFLAGS)' OPT='$(OPT)' \
491
+ _TCLTK_INCLUDES='$(TCLTK_INCLUDES)' _TCLTK_LIBS='$(TCLTK_LIBS)' \
492
+ $(PYTHON_FOR_BUILD) $(srcdir)/setup.py $$quiet build
493
+
494
+ # Build static library
495
+ # avoid long command lines, same as LIBRARY_OBJS
496
+ $(LIBRARY): $(LIBRARY_OBJS)
497
+ -rm -f $@
498
+ $(AR) $(ARFLAGS) $@ Modules/getbuildinfo.o
499
+ $(AR) $(ARFLAGS) $@ $(PARSER_OBJS)
500
+ $(AR) $(ARFLAGS) $@ $(OBJECT_OBJS)
501
+ $(AR) $(ARFLAGS) $@ $(PYTHON_OBJS)
502
+ $(AR) $(ARFLAGS) $@ $(MODULE_OBJS) $(SIGNAL_OBJS)
503
+ $(AR) $(ARFLAGS) $@ $(sort $(MODOBJS))
504
+ $(RANLIB) $@
505
+
506
+ libpython$(VERSION)$(DEBUG_EXT).so: $(LIBRARY_OBJS)
507
+ if test $(INSTSONAME) != $(LDLIBRARY); then \
508
+ $(BLDSHARED) $(PY_LDFLAGS) -Wl,-h$(INSTSONAME) -o $(INSTSONAME) $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
509
+ $(LN) -f $(INSTSONAME) $@; \
510
+ else \
511
+ $(BLDSHARED) $(PY_LDFLAGS) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
512
+ fi
513
+
514
+ libpython$(VERSION).dylib: $(LIBRARY_OBJS)
515
+ $(CC) -dynamiclib -Wl,-single_module $(PY_LDFLAGS) -undefined dynamic_lookup -Wl,-install_name,$(prefix)/lib/libpython$(VERSION).dylib -Wl,-compatibility_version,$(VERSION) -Wl,-current_version,$(VERSION) -o $@ $(LIBRARY_OBJS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST); \
516
+
517
+
518
+ libpython$(VERSION).sl: $(LIBRARY_OBJS)
519
+ $(LDSHARED) $(PY_LDFLAGS) -o $@ $(LIBRARY_OBJS) $(MODLIBS) $(SHLIBS) $(LIBC) $(LIBM) $(LDLAST)
520
+
521
+ # Copy up the gdb python hooks into a position where they can be automatically
522
+ # loaded by gdb during Lib/test/test_gdb.py
523
+ #
524
+ # Distributors are likely to want to install this somewhere else e.g. relative
525
+ # to the stripped DWARF data for the shared library.
526
+ gdbhooks: $(BUILDPYTHON)-gdb.py
527
+
528
+ SRC_GDB_HOOKS=$(srcdir)/Tools/gdb/libpython.py
529
+ $(BUILDPYTHON)-gdb.py: $(SRC_GDB_HOOKS)
530
+ $(INSTALL_DATA) $(SRC_GDB_HOOKS) $(BUILDPYTHON)-gdb.py
531
+
532
+ # This rule is here for OPENSTEP/Rhapsody/MacOSX. It builds a temporary
533
+ # minimal framework (not including the Lib directory and such) in the current
534
+ # directory.
535
+ RESSRCDIR=Mac/Resources/framework
536
+ $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK): \
537
+ $(LIBRARY) \
538
+ $(RESSRCDIR)/Info.plist
539
+ $(INSTALL) -d -m $(DIRMODE) $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)
540
+ $(CC) -o $(LDLIBRARY) $(LDFLAGS) -dynamiclib \
541
+ -all_load $(LIBRARY) -Wl,-single_module \
542
+ -install_name $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/$(VERSION)/$(PYTHONFRAMEWORK) \
543
+ -compatibility_version $(VERSION) \
544
+ -current_version $(VERSION);
545
+ $(INSTALL) -d -m $(DIRMODE) \
546
+ $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/English.lproj
547
+ $(INSTALL_DATA) $(RESSRCDIR)/Info.plist \
548
+ $(PYTHONFRAMEWORKDIR)/Versions/$(VERSION)/Resources/Info.plist
549
+ $(LN) -fsn $(VERSION) $(PYTHONFRAMEWORKDIR)/Versions/Current
550
+ $(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(PYTHONFRAMEWORKDIR)/$(PYTHONFRAMEWORK)
551
+ $(LN) -fsn Versions/Current/Headers $(PYTHONFRAMEWORKDIR)/Headers
552
+ $(LN) -fsn Versions/Current/Resources $(PYTHONFRAMEWORKDIR)/Resources
553
+
554
+ # This rule builds the Cygwin Python DLL and import library if configured
555
+ # for a shared core library; otherwise, this rule is a noop.
556
+ $(DLLLIBRARY) libpython$(VERSION).dll.a: $(LIBRARY_OBJS)
557
+ if test -n "$(DLLLIBRARY)"; then \
558
+ $(LDSHARED) $(PY_LDFLAGS) -Wl,--out-implib=$@ -o $(DLLLIBRARY) $^ \
559
+ $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST); \
560
+ else true; \
561
+ fi
562
+
563
+
564
+ oldsharedmods: $(SHAREDMODS)
565
+
566
+
567
+ Makefile Modules/config.c: Makefile.pre \
568
+ $(srcdir)/Modules/config.c.in \
569
+ $(MAKESETUP) \
570
+ Modules/Setup.config \
571
+ Modules/Setup \
572
+ Modules/Setup.local
573
+ $(SHELL) $(MAKESETUP) -c $(srcdir)/Modules/config.c.in \
574
+ -s Modules \
575
+ Modules/Setup.config \
576
+ Modules/Setup.local \
577
+ Modules/Setup
578
+ @mv config.c Modules
579
+ @echo "The Makefile was updated, you may need to re-run make."
580
+
581
+ Python/dynload_shlib.o: $(srcdir)/Python/dynload_shlib.c Makefile
582
+ $(CC) -c $(PY_CORE_CFLAGS) \
583
+ $(if $(MULTIARCH),-DMULTIARCH='"$(MULTIARCH)"') \
584
+ -o $@ $(srcdir)/Python/dynload_shlib.c
585
+
586
+ Modules/Setup: $(srcdir)/Modules/Setup.dist
587
+ @if test -f Modules/Setup; then \
588
+ echo "-----------------------------------------------"; \
589
+ echo "Modules/Setup.dist is newer than Modules/Setup;"; \
590
+ echo "check to make sure you have all the updates you"; \
591
+ echo "need in your Modules/Setup file."; \
592
+ echo "Usually, copying Modules/Setup.dist to Modules/Setup will work."; \
593
+ echo "-----------------------------------------------"; \
594
+ fi
595
+
596
+ ############################################################################
597
+ # Special rules for object files
598
+
599
+ Modules/getbuildinfo.o: $(PARSER_OBJS) \
600
+ $(OBJECT_OBJS) \
601
+ $(PYTHON_OBJS) \
602
+ $(MODULE_OBJS) \
603
+ $(SIGNAL_OBJS) \
604
+ $(MODOBJS) \
605
+ $(srcdir)/Modules/getbuildinfo.c
606
+ $(CC) -c $(PY_CORE_CFLAGS) \
607
+ -DSVNVERSION="\"`LC_ALL=C $(SVNVERSION)`\"" \
608
+ -DHGVERSION="\"`LC_ALL=C $(HGVERSION)`\"" \
609
+ -DHGTAG="\"`LC_ALL=C $(HGTAG)`\"" \
610
+ -DHGBRANCH="\"`LC_ALL=C $(HGBRANCH)`\"" \
611
+ -o $@ $(srcdir)/Modules/getbuildinfo.c
612
+
613
+ Modules/getpath.o: $(srcdir)/Modules/getpath.c Makefile
614
+ $(CC) -c $(PY_CORE_CFLAGS) -DPYTHONPATH='"$(PYTHONPATH)"' \
615
+ -DPREFIX='"$(prefix)"' \
616
+ -DEXEC_PREFIX='"$(exec_prefix)"' \
617
+ -DVERSION='"$(VERSION)"' \
618
+ -DVPATH='"$(VPATH)"' \
619
+ -o $@ $(srcdir)/Modules/getpath.c
620
+
621
+ Modules/python.o: $(srcdir)/Modules/python.c
622
+ $(MAINCC) -c $(PY_CORE_CFLAGS) -o $@ $(srcdir)/Modules/python.c
623
+
624
+ Modules/posixmodule.o: $(srcdir)/Modules/posixmodule.c $(srcdir)/Modules/posixmodule.h
625
+
626
+ Modules/grpmodule.o: $(srcdir)/Modules/grpmodule.c $(srcdir)/Modules/posixmodule.h
627
+
628
+ Modules/pwdmodule.o: $(srcdir)/Modules/pwdmodule.c $(srcdir)/Modules/posixmodule.h
629
+
630
+ $(GRAMMAR_H): $(GRAMMAR_INPUT) $(PGENSRCS)
631
+ @$(MKDIR_P) Include
632
+ $(MAKE) $(PGEN)
633
+ $(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
634
+ $(GRAMMAR_C): $(GRAMMAR_H) $(GRAMMAR_INPUT) $(PGENSRCS)
635
+ $(MAKE) $(GRAMMAR_H)
636
+ touch $(GRAMMAR_C)
637
+
638
+ $(PGEN): $(PGENOBJS)
639
+ $(CC) $(OPT) $(PY_LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
640
+
641
+ Parser/grammar.o: $(srcdir)/Parser/grammar.c \
642
+ $(srcdir)/Include/token.h \
643
+ $(srcdir)/Include/grammar.h
644
+ Parser/metagrammar.o: $(srcdir)/Parser/metagrammar.c
645
+
646
+ Parser/tokenizer_pgen.o: $(srcdir)/Parser/tokenizer.c
647
+
648
+ Parser/pgenmain.o: $(srcdir)/Include/parsetok.h
649
+
650
+ $(AST_H): $(AST_ASDL) $(ASDLGEN_FILES)
651
+ $(MKDIR_P) $(AST_H_DIR)
652
+ $(ASDLGEN) -h $(AST_H_DIR) $(AST_ASDL)
653
+
654
+ $(AST_C): $(AST_ASDL) $(ASDLGEN_FILES)
655
+ $(MKDIR_P) $(AST_C_DIR)
656
+ $(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL)
657
+
658
+ Python/compile.o Python/symtable.o Python/ast.o: $(GRAMMAR_H) $(AST_H)
659
+
660
+ Python/getplatform.o: $(srcdir)/Python/getplatform.c
661
+ $(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
662
+
663
+ Python/importdl.o: $(srcdir)/Python/importdl.c
664
+ $(CC) -c $(PY_CORE_CFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
665
+
666
+ Objects/unicodectype.o: $(srcdir)/Objects/unicodectype.c \
667
+ $(srcdir)/Objects/unicodetype_db.h
668
+
669
+ STRINGLIB_HEADERS= \
670
+ $(srcdir)/Include/bytes_methods.h \
671
+ $(srcdir)/Objects/stringlib/count.h \
672
+ $(srcdir)/Objects/stringlib/ctype.h \
673
+ $(srcdir)/Objects/stringlib/fastsearch.h \
674
+ $(srcdir)/Objects/stringlib/find.h \
675
+ $(srcdir)/Objects/stringlib/formatter.h \
676
+ $(srcdir)/Objects/stringlib/partition.h \
677
+ $(srcdir)/Objects/stringlib/split.h \
678
+ $(srcdir)/Objects/stringlib/stringdefs.h \
679
+ $(srcdir)/Objects/stringlib/string_format.h \
680
+ $(srcdir)/Objects/stringlib/transmogrify.h \
681
+ $(srcdir)/Objects/stringlib/unicodedefs.h \
682
+ $(srcdir)/Objects/stringlib/localeutil.h
683
+
684
+ Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c \
685
+ $(STRINGLIB_HEADERS)
686
+
687
+ Objects/bytearrayobject.o: $(srcdir)/Objects/bytearrayobject.c \
688
+ $(STRINGLIB_HEADERS)
689
+
690
+ Objects/stringobject.o: $(srcdir)/Objects/stringobject.c \
691
+ $(STRINGLIB_HEADERS)
692
+
693
+ Python/formatter_unicode.o: $(srcdir)/Python/formatter_unicode.c \
694
+ $(STRINGLIB_HEADERS)
695
+
696
+ Python/formatter_string.o: $(srcdir)/Python/formatter_string.c \
697
+ $(STRINGLIB_HEADERS)
698
+
699
+ ############################################################################
700
+ # Header files
701
+
702
+ PYTHON_HEADERS= \
703
+ Include/Python-ast.h \
704
+ Include/Python.h \
705
+ Include/abstract.h \
706
+ Include/asdl.h \
707
+ Include/ast.h \
708
+ Include/bitset.h \
709
+ Include/boolobject.h \
710
+ Include/bytearrayobject.h \
711
+ Include/bytes_methods.h \
712
+ Include/bytesobject.h \
713
+ Include/bufferobject.h \
714
+ Include/cellobject.h \
715
+ Include/ceval.h \
716
+ Include/classobject.h \
717
+ Include/cobject.h \
718
+ Include/code.h \
719
+ Include/codecs.h \
720
+ Include/compile.h \
721
+ Include/complexobject.h \
722
+ Include/descrobject.h \
723
+ Include/dictobject.h \
724
+ Include/dtoa.h \
725
+ Include/enumobject.h \
726
+ Include/errcode.h \
727
+ Include/eval.h \
728
+ Include/fileobject.h \
729
+ Include/floatobject.h \
730
+ Include/frameobject.h \
731
+ Include/funcobject.h \
732
+ Include/genobject.h \
733
+ Include/import.h \
734
+ Include/intobject.h \
735
+ Include/intrcheck.h \
736
+ Include/iterobject.h \
737
+ Include/listobject.h \
738
+ Include/longintrepr.h \
739
+ Include/longobject.h \
740
+ Include/marshal.h \
741
+ Include/memoryobject.h \
742
+ Include/metagrammar.h \
743
+ Include/methodobject.h \
744
+ Include/modsupport.h \
745
+ Include/moduleobject.h \
746
+ Include/node.h \
747
+ Include/object.h \
748
+ Include/objimpl.h \
749
+ Include/opcode.h \
750
+ Include/osdefs.h \
751
+ Include/parsetok.h \
752
+ Include/patchlevel.h \
753
+ Include/pgen.h \
754
+ Include/pgenheaders.h \
755
+ Include/pyarena.h \
756
+ Include/pycapsule.h \
757
+ Include/pyctype.h \
758
+ Include/pydebug.h \
759
+ Include/pyerrors.h \
760
+ Include/pyfpe.h \
761
+ Include/pymath.h \
762
+ Include/pygetopt.h \
763
+ Include/pymem.h \
764
+ Include/pyport.h \
765
+ Include/pystate.h \
766
+ Include/pystrcmp.h \
767
+ Include/pystrtod.h \
768
+ Include/pythonrun.h \
769
+ Include/pythread.h \
770
+ Include/rangeobject.h \
771
+ Include/setobject.h \
772
+ Include/sliceobject.h \
773
+ Include/stringobject.h \
774
+ Include/structmember.h \
775
+ Include/structseq.h \
776
+ Include/symtable.h \
777
+ Include/sysmodule.h \
778
+ Include/traceback.h \
779
+ Include/tupleobject.h \
780
+ Include/ucnhash.h \
781
+ Include/unicodeobject.h \
782
+ Include/warnings.h \
783
+ Include/weakrefobject.h \
784
+ pyconfig.h \
785
+ $(PARSER_HEADERS) \
786
+ $(AST_H)
787
+
788
+ $(LIBRARY_OBJS) $(MODOBJS) Modules/python.o: $(PYTHON_HEADERS)
789
+
790
+
791
+ ######################################################################
792
+
793
+ # Test the interpreter (twice, once without .pyc files, once with)
794
+ # In the past, we've had problems where bugs in the marshalling or
795
+ # elsewhere caused bytecode read from .pyc files to behave differently
796
+ # than bytecode generated directly from a .py source file. Sometimes
797
+ # the bytecode read from a .pyc file had the bug, sometimes the directly
798
+ # generated bytecode. This is sometimes a very shy bug needing a lot of
799
+ # sample data.
800
+
801
+ TESTOPTS= -l $(EXTRATESTOPTS)
802
+ TESTPROG= $(srcdir)/Lib/test/regrtest.py
803
+ TESTPYTHON= $(RUNSHARED) ./$(BUILDPYTHON) -Wd -3 -E -tt $(TESTPYTHONOPTS)
804
+ test: all platform
805
+ -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
806
+ -$(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
807
+ $(TESTPYTHON) $(TESTPROG) $(TESTOPTS)
808
+
809
+ testall: all platform
810
+ -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
811
+ $(TESTPYTHON) $(srcdir)/Lib/compileall.py
812
+ -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
813
+ -$(TESTPYTHON) $(TESTPROG) -uall $(TESTOPTS)
814
+ $(TESTPYTHON) $(TESTPROG) -uall $(TESTOPTS)
815
+
816
+ # Run the unitests for both architectures in a Universal build on OSX
817
+ # Must be run on an Intel box.
818
+ testuniversal: all platform
819
+ if [ `arch` != 'i386' ];then \
820
+ echo "This can only be used on OSX/i386" ;\
821
+ exit 1 ;\
822
+ fi
823
+ -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
824
+ -$(TESTPYTHON) $(TESTPROG) -uall $(TESTOPTS)
825
+ $(TESTPYTHON) $(TESTPROG) -uall $(TESTOPTS)
826
+ $(RUNSHARED) /usr/libexec/oah/translate ./$(BUILDPYTHON) -E -tt $(TESTPROG) -uall $(TESTOPTS)
827
+
828
+
829
+ # Like testall, but with a single pass only
830
+ # run an optional script to include some information about the build environment
831
+ buildbottest: all platform
832
+ -@if which pybuildbot.identify >/dev/null 2>&1; then \
833
+ pybuildbot.identify "CC='$(CC)'" "CXX='$(CXX)'"; \
834
+ fi
835
+ $(TESTPYTHON) -R $(TESTPROG) -uall -rwW $(TESTOPTS)
836
+
837
+ QUICKTESTOPTS= $(TESTOPTS) -x test_subprocess test_io test_lib2to3 \
838
+ test_multibytecodec test_urllib2_localnet test_itertools \
839
+ test_multiprocessing test_mailbox test_socket test_poll \
840
+ test_select test_zipfile
841
+ quicktest: all platform
842
+ -find $(srcdir)/Lib -name '*.py[co]' -print | xargs rm -f
843
+ -$(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
844
+ $(TESTPYTHON) $(TESTPROG) $(QUICKTESTOPTS)
845
+
846
+ MEMTESTOPTS= $(QUICKTESTOPTS) -x test_dl test___all__ test_fork1 \
847
+ test_longexp
848
+ memtest: all platform
849
+ -rm -f $(srcdir)/Lib/test/*.py[co]
850
+ -$(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
851
+ $(TESTPYTHON) $(TESTPROG) $(MEMTESTOPTS)
852
+
853
+ # Install everything
854
+ install: altinstall bininstall maninstall
855
+
856
+ # Install almost everything without disturbing previous versions
857
+ altinstall: altbininstall libinstall inclinstall \
858
+ libainstall altmaninstall \
859
+ sharedinstall oldsharedinstall
860
+
861
+ # Install shared libraries enabled by Setup
862
+ DESTDIRS= $(exec_prefix) $(LIBDIR) $(BINLIBDEST) $(DESTSHARED)
863
+
864
+ oldsharedinstall: $(DESTSHARED) $(SHAREDMODS)
865
+ @for i in X $(SHAREDMODS); do \
866
+ if test $$i != X; then \
867
+ echo $(INSTALL_SHARED) $$i $(DESTSHARED)/`basename $$i`; \
868
+ $(INSTALL_SHARED) $$i $(DESTDIR)$(DESTSHARED)/`basename $$i`; \
869
+ fi; \
870
+ done
871
+
872
+ $(DESTSHARED):
873
+ @for i in $(DESTDIRS); \
874
+ do \
875
+ if test ! -d $(DESTDIR)$$i; then \
876
+ echo "Creating directory $$i"; \
877
+ $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
878
+ else true; \
879
+ fi; \
880
+ done
881
+
882
+
883
+ # Install the interpreter by creating a symlink chain:
884
+ # $(PYTHON) -> python2 -> python$(VERSION))
885
+ # Also create equivalent chains for other installed files
886
+ bininstall: altbininstall
887
+ -if test -f $(DESTDIR)$(BINDIR)/$(PYTHON) -o -h $(DESTDIR)$(BINDIR)/$(PYTHON); \
888
+ then rm -f $(DESTDIR)$(BINDIR)/$(PYTHON); \
889
+ else true; \
890
+ fi
891
+ (cd $(DESTDIR)$(BINDIR); $(LN) -s python2$(EXE) $(PYTHON))
892
+ -rm -f $(DESTDIR)$(BINDIR)/python2$(EXE)
893
+ (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)$(EXE) python2$(EXE))
894
+ -rm -f $(DESTDIR)$(BINDIR)/python2-config
895
+ (cd $(DESTDIR)$(BINDIR); $(LN) -s python$(VERSION)-config python2-config)
896
+ -rm -f $(DESTDIR)$(BINDIR)/python-config
897
+ (cd $(DESTDIR)$(BINDIR); $(LN) -s python2-config python-config)
898
+ -test -d $(DESTDIR)$(LIBPC) || $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$(LIBPC)
899
+ -rm -f $(DESTDIR)$(LIBPC)/python2.pc
900
+ (cd $(DESTDIR)$(LIBPC); $(LN) -s python-$(VERSION).pc python2.pc)
901
+ -rm -f $(DESTDIR)$(LIBPC)/python.pc
902
+ (cd $(DESTDIR)$(LIBPC); $(LN) -s python2.pc python.pc)
903
+
904
+ # Install the interpreter with $(VERSION) affixed
905
+ # This goes into $(exec_prefix)
906
+ altbininstall: $(BUILDPYTHON)
907
+ @for i in $(BINDIR) $(LIBDIR); \
908
+ do \
909
+ if test ! -d $(DESTDIR)$$i; then \
910
+ echo "Creating directory $$i"; \
911
+ $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
912
+ else true; \
913
+ fi; \
914
+ done
915
+ $(INSTALL_PROGRAM) $(BUILDPYTHON) $(DESTDIR)$(BINDIR)/python$(VERSION)$(EXE)
916
+ if test -f $(LDLIBRARY); then \
917
+ if test -n "$(DLLLIBRARY)" ; then \
918
+ $(INSTALL_SHARED) $(DLLLIBRARY) $(DESTDIR)$(BINDIR); \
919
+ else \
920
+ $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(LIBDIR)/$(INSTSONAME); \
921
+ if test $(LDLIBRARY) != $(INSTSONAME); then \
922
+ (cd $(DESTDIR)$(LIBDIR); $(LN) -sf $(INSTSONAME) $(LDLIBRARY)) \
923
+ fi \
924
+ fi; \
925
+ else true; \
926
+ fi
927
+
928
+ # Install the versioned manual page
929
+ altmaninstall:
930
+ @for i in $(MANDIR) $(MANDIR)/man1; \
931
+ do \
932
+ if test ! -d $(DESTDIR)$$i; then \
933
+ echo "Creating directory $$i"; \
934
+ $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
935
+ else true; \
936
+ fi; \
937
+ done
938
+ $(INSTALL_DATA) $(srcdir)/Misc/python.man \
939
+ $(DESTDIR)$(MANDIR)/man1/python$(VERSION).1
940
+
941
+ # Install the unversioned manual pages
942
+ maninstall: altmaninstall
943
+ -rm -f $(DESTDIR)$(MANDIR)/man1/python2.1
944
+ (cd $(DESTDIR)$(MANDIR)/man1; $(LN) -s python$(VERSION).1 python2.1)
945
+ -rm -f $(DESTDIR)$(MANDIR)/man1/python.1
946
+ (cd $(DESTDIR)$(MANDIR)/man1; $(LN) -s python2.1 python.1)
947
+
948
+ # Install the library
949
+ PLATDIR= plat-$(MULTIARCH)
950
+ EXTRAPLATDIR=
951
+ EXTRAMACHDEPPATH=
952
+ MACHDEPS= $(PLATDIR) $(EXTRAPLATDIR)
953
+ XMLLIBSUBDIRS= xml xml/dom xml/etree xml/parsers xml/sax
954
+ PLATMACDIRS= plat-mac plat-mac/Carbon plat-mac/lib-scriptpackages \
955
+ plat-mac/lib-scriptpackages/_builtinSuites \
956
+ plat-mac/lib-scriptpackages/CodeWarrior \
957
+ plat-mac/lib-scriptpackages/Explorer \
958
+ plat-mac/lib-scriptpackages/Finder \
959
+ plat-mac/lib-scriptpackages/Netscape \
960
+ plat-mac/lib-scriptpackages/StdSuites \
961
+ plat-mac/lib-scriptpackages/SystemEvents \
962
+ plat-mac/lib-scriptpackages/Terminal
963
+ PLATMACPATH=:plat-mac:plat-mac/lib-scriptpackages
964
+ LIBSUBDIRS= lib-tk lib-tk/test lib-tk/test/test_tkinter \
965
+ lib-tk/test/test_ttk site-packages test test/audiodata test/data \
966
+ test/cjkencodings test/decimaltestdata test/xmltestdata \
967
+ test/imghdrdata \
968
+ test/subprocessdata \
969
+ test/tracedmodules \
970
+ encodings compiler hotshot \
971
+ email email/mime email/test email/test/data \
972
+ json json/tests \
973
+ sqlite3 sqlite3/test \
974
+ logging bsddb bsddb/test csv importlib wsgiref \
975
+ lib2to3 lib2to3/fixes lib2to3/pgen2 lib2to3/tests \
976
+ lib2to3/tests/data lib2to3/tests/data/fixers lib2to3/tests/data/fixers/myfixes \
977
+ ctypes ctypes/test ctypes/macholib \
978
+ idlelib idlelib/Icons idlelib/idle_test \
979
+ distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \
980
+ multiprocessing multiprocessing/dummy \
981
+ unittest unittest/test \
982
+ lib-old \
983
+ curses pydoc_data $(MACHDEPS)
984
+ libinstall: build_all $(srcdir)/Lib/$(PLATDIR) $(srcdir)/Modules/xxmodule.c
985
+ @for i in $(SCRIPTDIR) $(LIBDEST); \
986
+ do \
987
+ if test ! -d $(DESTDIR)$$i; then \
988
+ echo "Creating directory $$i"; \
989
+ $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
990
+ else true; \
991
+ fi; \
992
+ done
993
+ @for d in $(LIBSUBDIRS); \
994
+ do \
995
+ a=$(srcdir)/Lib/$$d; \
996
+ if test ! -d $$a; then continue; else true; fi; \
997
+ b=$(LIBDEST)/$$d; \
998
+ if test ! -d $(DESTDIR)$$b; then \
999
+ echo "Creating directory $$b"; \
1000
+ $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$b; \
1001
+ else true; \
1002
+ fi; \
1003
+ done
1004
+ @for i in $(srcdir)/Lib/*.py `cat pybuilddir.txt`/_sysconfigdata.py $(srcdir)/Lib/*.doc $(srcdir)/Lib/*.egg-info ; \
1005
+ do \
1006
+ if test -x $$i; then \
1007
+ $(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
1008
+ echo $(INSTALL_SCRIPT) $$i $(LIBDEST); \
1009
+ else \
1010
+ $(INSTALL_DATA) $$i $(DESTDIR)$(LIBDEST); \
1011
+ echo $(INSTALL_DATA) $$i $(LIBDEST); \
1012
+ fi; \
1013
+ done
1014
+ @for d in $(LIBSUBDIRS); \
1015
+ do \
1016
+ a=$(srcdir)/Lib/$$d; \
1017
+ if test ! -d $$a; then continue; else true; fi; \
1018
+ if test `ls $$a | wc -l` -lt 1; then continue; fi; \
1019
+ b=$(LIBDEST)/$$d; \
1020
+ for i in $$a/*; \
1021
+ do \
1022
+ case $$i in \
1023
+ *CVS) ;; \
1024
+ *.py[co]) ;; \
1025
+ *.orig) ;; \
1026
+ *~) ;; \
1027
+ *) \
1028
+ if test -d $$i; then continue; fi; \
1029
+ if test -x $$i; then \
1030
+ echo $(INSTALL_SCRIPT) $$i $$b; \
1031
+ $(INSTALL_SCRIPT) $$i $(DESTDIR)$$b; \
1032
+ else \
1033
+ echo $(INSTALL_DATA) $$i $$b; \
1034
+ $(INSTALL_DATA) $$i $(DESTDIR)$$b; \
1035
+ fi;; \
1036
+ esac; \
1037
+ done; \
1038
+ done
1039
+ $(INSTALL_DATA) $(srcdir)/LICENSE $(DESTDIR)$(LIBDEST)/LICENSE.txt
1040
+ if test -d $(DESTDIR)$(LIBDEST)/distutils/tests; then \
1041
+ $(INSTALL_DATA) $(srcdir)/Modules/xxmodule.c \
1042
+ $(DESTDIR)$(LIBDEST)/distutils/tests ; \
1043
+ fi
1044
+ PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
1045
+ $(PYTHON_FOR_BUILD) -Wi -tt $(DESTDIR)$(LIBDEST)/compileall.py \
1046
+ -d $(LIBDEST) -f \
1047
+ -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
1048
+ $(DESTDIR)$(LIBDEST)
1049
+ PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
1050
+ $(PYTHON_FOR_BUILD) -Wi -tt -O $(DESTDIR)$(LIBDEST)/compileall.py \
1051
+ -d $(LIBDEST) -f \
1052
+ -x 'bad_coding|badsyntax|site-packages|lib2to3/tests/data' \
1053
+ $(DESTDIR)$(LIBDEST)
1054
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
1055
+ $(PYTHON_FOR_BUILD) -Wi -t $(DESTDIR)$(LIBDEST)/compileall.py \
1056
+ -d $(LIBDEST)/site-packages -f \
1057
+ -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
1058
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
1059
+ $(PYTHON_FOR_BUILD) -Wi -t -O $(DESTDIR)$(LIBDEST)/compileall.py \
1060
+ -d $(LIBDEST)/site-packages -f \
1061
+ -x badsyntax $(DESTDIR)$(LIBDEST)/site-packages
1062
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
1063
+ $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/Grammar.txt
1064
+ -PYTHONPATH=$(DESTDIR)$(LIBDEST) $(RUNSHARED) \
1065
+ $(PYTHON_FOR_BUILD) -m lib2to3.pgen2.driver $(DESTDIR)$(LIBDEST)/lib2to3/PatternGrammar.txt
1066
+
1067
+ # Create the PLATDIR source directory, if one wasn't distributed..
1068
+ $(srcdir)/Lib/$(PLATDIR):
1069
+ mkdir $(srcdir)/Lib/$(PLATDIR)
1070
+ cp $(srcdir)/Lib/plat-generic/regen $(srcdir)/Lib/$(PLATDIR)/regen
1071
+ export PATH; PATH="`pwd`:$$PATH"; \
1072
+ export PYTHONPATH; PYTHONPATH="$(srcdir)/Lib:$(abs_builddir)/`cat pybuilddir.txt`"; \
1073
+ export DYLD_FRAMEWORK_PATH; DYLD_FRAMEWORK_PATH="`pwd`"; \
1074
+ export EXE; EXE="$(BUILDEXE)"; \
1075
+ if [ -n "$(MULTIARCH)" ]; then export MULTIARCH; MULTIARCH=$(MULTIARCH); fi; \
1076
+ export PYTHON_FOR_BUILD; \
1077
+ if [ "$(build)" = "$(host)" ]; then \
1078
+ PYTHON_FOR_BUILD="$(BUILDPYTHON)"; \
1079
+ else \
1080
+ PYTHON_FOR_BUILD="$(PYTHON_FOR_BUILD)"; \
1081
+ fi; \
1082
+ cd $(srcdir)/Lib/$(PLATDIR); $(RUNSHARED) ./regen
1083
+
1084
+ python-config: $(srcdir)/Misc/python-config.in
1085
+ # Substitution happens here, as the completely-expanded BINDIR
1086
+ # is not available in configure
1087
+ sed -e "s,@EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
1088
+ # Replace makefile compat. variable references with shell script compat. ones; $(VAR) -> ${VAR}
1089
+ sed -e "s,\$$(\([A-Za-z0-9_]*\)),\$$\{\1\},g" < Misc/python-config.sh >python-config.sh
1090
+
1091
+ # Install the include files
1092
+ INCLDIRSTOMAKE=$(INCLUDEDIR) $(CONFINCLUDEDIR) $(INCLUDEPY) $(CONFINCLUDEPY)
1093
+ inclinstall:
1094
+ @for i in $(INCLDIRSTOMAKE); \
1095
+ do \
1096
+ if test ! -d $(DESTDIR)$$i; then \
1097
+ echo "Creating directory $$i"; \
1098
+ $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1099
+ else true; \
1100
+ fi; \
1101
+ done
1102
+ @for i in $(srcdir)/Include/*.h; \
1103
+ do \
1104
+ echo $(INSTALL_DATA) $$i $(INCLUDEPY); \
1105
+ $(INSTALL_DATA) $$i $(DESTDIR)$(INCLUDEPY); \
1106
+ done
1107
+ $(INSTALL_DATA) pyconfig.h $(DESTDIR)$(CONFINCLUDEPY)/pyconfig.h
1108
+
1109
+ # Install the library and miscellaneous stuff needed for extending/embedding
1110
+ # This goes into $(exec_prefix)$(DEBUG_EXT)
1111
+ LIBPL= $(LIBP)/config-$(MULTIARCH)$(DEBUG_EXT)
1112
+
1113
+ # pkgconfig directory
1114
+ LIBPC= $(LIBDIR)/$(MULTIARCH)/pkgconfig
1115
+
1116
+ libainstall: all python-config
1117
+ @for i in $(LIBDIR) $(LIBP) $(LIBPL) $(LIBPC); \
1118
+ do \
1119
+ if test ! -d $(DESTDIR)$$i; then \
1120
+ echo "Creating directory $$i"; \
1121
+ $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1122
+ else true; \
1123
+ fi; \
1124
+ done
1125
+ @if test -d $(LIBRARY); then :; else \
1126
+ if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
1127
+ if test "$(SO)" = .dll; then \
1128
+ $(INSTALL_DATA) $(LDLIBRARY) $(DESTDIR)$(LIBPL) ; \
1129
+ else \
1130
+ $(INSTALL_DATA) $(LIBRARY) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
1131
+ $(RANLIB) $(DESTDIR)$(LIBPL)/$(LIBRARY) ; \
1132
+ fi; \
1133
+ else \
1134
+ echo Skip install of $(LIBRARY) - use make frameworkinstall; \
1135
+ fi; \
1136
+ fi
1137
+ $(INSTALL_DATA) Modules/config.c $(DESTDIR)$(LIBPL)/config.c
1138
+ $(INSTALL_DATA) Modules/python.o $(DESTDIR)$(LIBPL)/python.o
1139
+ $(INSTALL_DATA) $(srcdir)/Modules/config.c.in $(DESTDIR)$(LIBPL)/config.c.in
1140
+ $(INSTALL_DATA) Makefile $(DESTDIR)$(LIBPL)/Makefile
1141
+ $(INSTALL_DATA) Modules/Setup $(DESTDIR)$(LIBPL)/Setup
1142
+ $(INSTALL_DATA) Modules/Setup.local $(DESTDIR)$(LIBPL)/Setup.local
1143
+ $(INSTALL_DATA) Modules/Setup.config $(DESTDIR)$(LIBPL)/Setup.config
1144
+ $(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc
1145
+ $(INSTALL_SCRIPT) $(srcdir)/Modules/makesetup $(DESTDIR)$(LIBPL)/makesetup
1146
+ $(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
1147
+ $(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
1148
+ rm python-config
1149
+ $(INSTALL_SCRIPT) python-config.sh $(DESTDIR)$(BINDIR)/python-config.sh
1150
+ @if [ -s Modules/python.exp -a \
1151
+ "`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
1152
+ echo; echo "Installing support files for building shared extension modules on AIX:"; \
1153
+ $(INSTALL_DATA) Modules/python.exp \
1154
+ $(DESTDIR)$(LIBPL)/python.exp; \
1155
+ echo; echo "$(LIBPL)/python.exp"; \
1156
+ $(INSTALL_SCRIPT) $(srcdir)/Modules/makexp_aix \
1157
+ $(DESTDIR)$(LIBPL)/makexp_aix; \
1158
+ echo "$(LIBPL)/makexp_aix"; \
1159
+ $(INSTALL_SCRIPT) $(srcdir)/Modules/ld_so_aix \
1160
+ $(DESTDIR)$(LIBPL)/ld_so_aix; \
1161
+ echo "$(LIBPL)/ld_so_aix"; \
1162
+ echo; echo "See Misc/AIX-NOTES for details."; \
1163
+ else true; \
1164
+ fi
1165
+ @case "$(MACHDEP)" in beos*) \
1166
+ echo; echo "Installing support files for building shared extension modules on BeOS:"; \
1167
+ $(INSTALL_DATA) Misc/BeOS-NOTES $(DESTDIR)$(LIBPL)/README; \
1168
+ echo; echo "$(LIBPL)/README"; \
1169
+ $(INSTALL_SCRIPT) Modules/ar_beos $(DESTDIR)$(LIBPL)/ar_beos; \
1170
+ echo "$(LIBPL)/ar_beos"; \
1171
+ $(INSTALL_SCRIPT) Modules/ld_so_beos $(DESTDIR)$(LIBPL)/ld_so_beos; \
1172
+ echo "$(LIBPL)/ld_so_beos"; \
1173
+ echo; echo "See Misc/BeOS-NOTES for details."; \
1174
+ ;; \
1175
+ esac
1176
+
1177
+ # Install the dynamically loadable modules
1178
+ # This goes into $(exec_prefix)
1179
+ sharedinstall: sharedmods
1180
+ $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/setup.py install \
1181
+ --prefix=$(prefix) \
1182
+ --install-scripts=$(BINDIR) \
1183
+ --install-platlib=$(DESTSHARED) \
1184
+ --root=$(DESTDIR)/
1185
+ -rm $(DESTDIR)$(DESTSHARED)/_sysconfigdata.py*
1186
+
1187
+ # Here are a couple of targets for MacOSX again, to install a full
1188
+ # framework-based Python. frameworkinstall installs everything, the
1189
+ # subtargets install specific parts. Much of the actual work is offloaded to
1190
+ # the Makefile in Mac
1191
+ #
1192
+ #
1193
+ # This target is here for backward compatiblity, previous versions of Python
1194
+ # hadn't integrated framework installation in the normal install process.
1195
+ frameworkinstall: install
1196
+
1197
+ # On install, we re-make the framework
1198
+ # structure in the install location, /Library/Frameworks/ or the argument to
1199
+ # --enable-framework. If --enable-framework has been specified then we have
1200
+ # automatically set prefix to the location deep down in the framework, so we
1201
+ # only have to cater for the structural bits of the framework.
1202
+
1203
+ frameworkinstallframework: frameworkinstallstructure install frameworkinstallmaclib
1204
+
1205
+ frameworkinstallstructure: $(LDLIBRARY)
1206
+ @if test "$(PYTHONFRAMEWORKDIR)" = no-framework; then \
1207
+ echo Not configured with --enable-framework; \
1208
+ exit 1; \
1209
+ else true; \
1210
+ fi
1211
+ @for i in $(prefix)/Resources/English.lproj $(prefix)/lib; do\
1212
+ if test ! -d $(DESTDIR)$$i; then \
1213
+ echo "Creating directory $(DESTDIR)$$i"; \
1214
+ $(INSTALL) -d -m $(DIRMODE) $(DESTDIR)$$i; \
1215
+ else true; \
1216
+ fi; \
1217
+ done
1218
+ $(LN) -fsn include/python$(VERSION) $(DESTDIR)$(prefix)/Headers
1219
+ sed 's/%VERSION%/'"`$(RUNSHARED) ./$(BUILDPYTHON) -c 'import platform; print platform.python_version()'`"'/g' < $(RESSRCDIR)/Info.plist > $(DESTDIR)$(prefix)/Resources/Info.plist
1220
+ $(LN) -fsn $(VERSION) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Versions/Current
1221
+ $(LN) -fsn Versions/Current/$(PYTHONFRAMEWORK) $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/$(PYTHONFRAMEWORK)
1222
+ $(LN) -fsn Versions/Current/Headers $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Headers
1223
+ $(LN) -fsn Versions/Current/Resources $(DESTDIR)$(PYTHONFRAMEWORKINSTALLDIR)/Resources
1224
+ $(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(LDLIBRARY)
1225
+
1226
+ # This installs Mac/Lib into the framework
1227
+ # Install a number of symlinks to keep software that expects a normal unix
1228
+ # install (which includes python-config) happy.
1229
+ frameworkinstallmaclib:
1230
+ ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).a"
1231
+ ln -fs "../../../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).dylib"
1232
+ ln -fs "../$(PYTHONFRAMEWORK)" "$(DESTDIR)$(prefix)/lib/libpython$(VERSION).dylib"
1233
+ cd Mac && $(MAKE) installmacsubtree DESTDIR="$(DESTDIR)"
1234
+
1235
+ # This installs the IDE, the Launcher and other apps into /Applications
1236
+ frameworkinstallapps:
1237
+ cd Mac && $(MAKE) installapps DESTDIR="$(DESTDIR)"
1238
+
1239
+ # This install the unix python and pythonw tools in /usr/local/bin
1240
+ frameworkinstallunixtools:
1241
+ cd Mac && $(MAKE) installunixtools DESTDIR="$(DESTDIR)"
1242
+
1243
+ frameworkaltinstallunixtools:
1244
+ cd Mac && $(MAKE) altinstallunixtools DESTDIR="$(DESTDIR)"
1245
+
1246
+ # This installs the Demos and Tools into the applications directory.
1247
+ # It is not part of a normal frameworkinstall
1248
+ frameworkinstallextras:
1249
+ cd Mac && $(MAKE) installextras DESTDIR="$(DESTDIR)"
1250
+
1251
+ # This installs a few of the useful scripts in Tools/scripts
1252
+ scriptsinstall:
1253
+ SRCDIR=$(srcdir) $(RUNSHARED) \
1254
+ $(PYTHON_FOR_BUILD) $(srcdir)/Tools/scripts/setup.py install \
1255
+ --prefix=$(prefix) \
1256
+ --install-scripts=$(BINDIR) \
1257
+ --root=$(DESTDIR)/
1258
+
1259
+ # Build the toplevel Makefile
1260
+ Makefile.pre: Makefile.pre.in config.status
1261
+ CONFIG_FILES=Makefile.pre CONFIG_HEADERS= $(SHELL) config.status
1262
+ $(MAKE) -f Makefile.pre Makefile
1263
+
1264
+ # Run the configure script.
1265
+ config.status: $(srcdir)/configure
1266
+ $(SHELL) $(srcdir)/configure $(CONFIG_ARGS)
1267
+
1268
+ .PRECIOUS: config.status $(BUILDPYTHON) Makefile Makefile.pre
1269
+
1270
+ # Some make's put the object file in the current directory
1271
+ .c.o:
1272
+ $(CC) -c $(PY_CORE_CFLAGS) -o $@ $<
1273
+
1274
+ # Run reindent on the library
1275
+ reindent:
1276
+ ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/reindent.py -r $(srcdir)/Lib
1277
+
1278
+ # Rerun configure with the same options as it was run last time,
1279
+ # provided the config.status script exists
1280
+ recheck:
1281
+ $(SHELL) config.status --recheck
1282
+ $(SHELL) config.status
1283
+
1284
+ # Rebuild the configure script from configure.ac; also rebuild pyconfig.h.in
1285
+ autoconf:
1286
+ (cd $(srcdir); autoconf)
1287
+ (cd $(srcdir); autoheader)
1288
+
1289
+ # Create a tags file for vi
1290
+ tags::
1291
+ cd $(srcdir); \
1292
+ ctags -w -t Include/*.h; \
1293
+ for i in $(SRCDIRS); do ctags -w -t -a $$i/*.[ch]; \
1294
+ done; \
1295
+ sort -o tags tags
1296
+
1297
+ # Create a tags file for GNU Emacs
1298
+ TAGS::
1299
+ cd $(srcdir); \
1300
+ etags Include/*.h; \
1301
+ for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done
1302
+
1303
+ # Touch generated files
1304
+ touch:
1305
+ touch Include/Python-ast.h Python/Python-ast.c
1306
+
1307
+ # Sanitation targets -- clean leaves libraries, executables and tags
1308
+ # files, which clobber removes as well
1309
+ pycremoval:
1310
+ find $(srcdir) -name '*.py[co]' -exec rm -f {} ';'
1311
+
1312
+ clean: pycremoval
1313
+ find . -name '*.[oa]' -exec rm -f {} ';'
1314
+ find . -name '*.s[ol]' -exec rm -f {} ';'
1315
+ find . -name '*.so.[0-9]*.[0-9]*' -exec rm -f {} ';'
1316
+ find build -name 'fficonfig.h' -exec rm -f {} ';' || true
1317
+ find build -name 'fficonfig.py' -exec rm -f {} ';' || true
1318
+ -rm -f Lib/lib2to3/*Grammar*.pickle
1319
+
1320
+ profile-removal:
1321
+ find . -name '*.gc??' -exec rm -f {} ';'
1322
+
1323
+ clobber: clean profile-removal
1324
+ -rm -f $(BUILDPYTHON) $(PGEN) $(LIBRARY) $(LDLIBRARY) $(DLLLIBRARY) \
1325
+ tags TAGS \
1326
+ config.cache config.log pyconfig.h Modules/config.c
1327
+ -rm -rf build platform
1328
+ -rm -rf $(PYTHONFRAMEWORKDIR)
1329
+
1330
+ # Make things extra clean, before making a distribution:
1331
+ # remove all generated files, even Makefile[.pre]
1332
+ # Keep configure and Python-ast.[ch], it's possible they can't be generated
1333
+ distclean: clobber
1334
+ for file in Lib/test/data/* ; do \
1335
+ if test "$$file" != "Lib/test/data/README"; then rm "$$file"; fi; \
1336
+ done
1337
+ -rm -f core Makefile Makefile.pre config.status \
1338
+ Modules/Setup Modules/Setup.local Modules/Setup.config \
1339
+ Modules/ld_so_aix Modules/python.exp Misc/python.pc
1340
+ -rm -f python*-gdb.py
1341
+ -rm -f pybuilddir.txt
1342
+ find $(srcdir)/[a-zA-Z]* '(' -name '*.fdc' -o -name '*~' \
1343
+ -o -name '[@,#]*' -o -name '*.old' \
1344
+ -o -name '*.orig' -o -name '*.rej' \
1345
+ -o -name '*.bak' ')' \
1346
+ -exec rm -f {} ';'
1347
+
1348
+ # Check for smelly exported symbols (not starting with Py/_Py)
1349
+ smelly: all
1350
+ nm -p $(LIBRARY) | \
1351
+ sed -n "/ [TDB] /s/.* //p" | grep -v "^_*Py" | sort -u; \
1352
+
1353
+ # Find files with funny names
1354
+ funny:
1355
+ find $(SUBDIRS) $(SUBDIRSTOO) -type d \
1356
+ -o -name '*.[chs]' \
1357
+ -o -name '*.py' \
1358
+ -o -name '*.doc' \
1359
+ -o -name '*.sty' \
1360
+ -o -name '*.bib' \
1361
+ -o -name '*.dat' \
1362
+ -o -name '*.el' \
1363
+ -o -name '*.fd' \
1364
+ -o -name '*.in' \
1365
+ -o -name '*.tex' \
1366
+ -o -name '*,[vpt]' \
1367
+ -o -name 'Setup' \
1368
+ -o -name 'Setup.*' \
1369
+ -o -name README \
1370
+ -o -name Makefile \
1371
+ -o -name ChangeLog \
1372
+ -o -name Repository \
1373
+ -o -name Root \
1374
+ -o -name Entries \
1375
+ -o -name Tag \
1376
+ -o -name tags \
1377
+ -o -name TAGS \
1378
+ -o -name .cvsignore \
1379
+ -o -name MANIFEST \
1380
+ -o -print
1381
+
1382
+ # Perform some verification checks on any modified files.
1383
+ patchcheck:
1384
+ $(RUNSHARED) ./$(BUILDPYTHON) $(srcdir)/Tools/scripts/patchcheck.py
1385
+
1386
+ # Dependencies
1387
+
1388
+ Python/thread.o: $(srcdir)/Python/thread_atheos.h $(srcdir)/Python/thread_beos.h $(srcdir)/Python/thread_cthread.h $(srcdir)/Python/thread_foobar.h $(srcdir)/Python/thread_lwp.h $(srcdir)/Python/thread_nt.h $(srcdir)/Python/thread_os2.h $(srcdir)/Python/thread_pth.h $(srcdir)/Python/thread_pthread.h $(srcdir)/Python/thread_sgi.h $(srcdir)/Python/thread_solaris.h $(srcdir)/Python/thread_wince.h
1389
+
1390
+ Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile
1391
+ $(CC) -c $(PY_CORE_CFLAGS) \
1392
+ -DMULTIARCH='"$(MULTIARCH)"' \
1393
+ -o $@ $(srcdir)/Python/sysmodule.c
1394
+
1395
+ # Declare targets that aren't real files
1396
+ .PHONY: all build_all sharedmods oldsharedmods test quicktest memtest
1397
+ .PHONY: install altinstall oldsharedinstall bininstall altbininstall
1398
+ .PHONY: maninstall libinstall inclinstall libainstall sharedinstall
1399
+ .PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
1400
+ .PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
1401
+ .PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean
1402
+ .PHONY: smelly funny patchcheck touch altmaninstall
1403
+ .PHONY: gdbhooks
1404
+
1405
+ # IF YOU PUT ANYTHING HERE IT WILL GO AWAY
1406
+
1407
+ # Rules appended by makedepend
1408
+
1409
+ Modules/threadmodule.o: $(srcdir)/Modules/threadmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/threadmodule.c -o Modules/threadmodule.o
1410
+ Modules/threadmodule$(SO): Modules/threadmodule.o; $(BLDSHARED) Modules/threadmodule.o -o Modules/threadmodule$(SO)
1411
+ Modules/signalmodule.o: $(srcdir)/Modules/signalmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/signalmodule.c -o Modules/signalmodule.o
1412
+ Modules/signalmodule$(SO): Modules/signalmodule.o; $(BLDSHARED) Modules/signalmodule.o -o Modules/signalmodule$(SO)
1413
+ Modules/arraymodule.o: $(srcdir)/Modules/arraymodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/arraymodule.c -o Modules/arraymodule.o
1414
+ Modules/arraymodule$(SO): Modules/arraymodule.o; $(BLDSHARED) Modules/arraymodule.o -o Modules/arraymodule$(SO)
1415
+ Modules/cmathmodule.o: $(srcdir)/Modules/cmathmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/cmathmodule.c -o Modules/cmathmodule.o
1416
+ Modules/cmathmodule$(SO): Modules/cmathmodule.o; $(BLDSHARED) Modules/cmathmodule.o -o Modules/cmathmodule$(SO)
1417
+ Modules/mathmodule.o: $(srcdir)/Modules/mathmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/mathmodule.c -o Modules/mathmodule.o
1418
+ Modules/_math.o: $(srcdir)/Modules/_math.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/_math.c -o Modules/_math.o
1419
+ Modules/math$(SO): Modules/mathmodule.o Modules/_math.o; $(BLDSHARED) Modules/mathmodule.o Modules/_math.o -o Modules/math$(SO)
1420
+ Modules/_struct.o: $(srcdir)/Modules/_struct.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/_struct.c -o Modules/_struct.o
1421
+ Modules/_struct$(SO): Modules/_struct.o; $(BLDSHARED) Modules/_struct.o -o Modules/_struct$(SO)
1422
+ Modules/timemodule.o: $(srcdir)/Modules/timemodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/timemodule.c -o Modules/timemodule.o
1423
+ Modules/timemodule$(SO): Modules/timemodule.o; $(BLDSHARED) Modules/timemodule.o -o Modules/timemodule$(SO)
1424
+ Modules/operator.o: $(srcdir)/Modules/operator.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/operator.c -o Modules/operator.o
1425
+ Modules/operator$(SO): Modules/operator.o; $(BLDSHARED) Modules/operator.o -o Modules/operator$(SO)
1426
+ Modules/_randommodule.o: $(srcdir)/Modules/_randommodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/_randommodule.c -o Modules/_randommodule.o
1427
+ Modules/_randommodule$(SO): Modules/_randommodule.o; $(BLDSHARED) Modules/_randommodule.o -o Modules/_randommodule$(SO)
1428
+ Modules/_collectionsmodule.o: $(srcdir)/Modules/_collectionsmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/_collectionsmodule.c -o Modules/_collectionsmodule.o
1429
+ Modules/_collectionsmodule$(SO): Modules/_collectionsmodule.o; $(BLDSHARED) Modules/_collectionsmodule.o -o Modules/_collectionsmodule$(SO)
1430
+ Modules/_heapqmodule.o: $(srcdir)/Modules/_heapqmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/_heapqmodule.c -o Modules/_heapqmodule.o
1431
+ Modules/_heapqmodule$(SO): Modules/_heapqmodule.o; $(BLDSHARED) Modules/_heapqmodule.o -o Modules/_heapqmodule$(SO)
1432
+ Modules/itertoolsmodule.o: $(srcdir)/Modules/itertoolsmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/itertoolsmodule.c -o Modules/itertoolsmodule.o
1433
+ Modules/itertoolsmodule$(SO): Modules/itertoolsmodule.o; $(BLDSHARED) Modules/itertoolsmodule.o -o Modules/itertoolsmodule$(SO)
1434
+ Modules/stropmodule.o: $(srcdir)/Modules/stropmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/stropmodule.c -o Modules/stropmodule.o
1435
+ Modules/stropmodule$(SO): Modules/stropmodule.o; $(BLDSHARED) Modules/stropmodule.o -o Modules/stropmodule$(SO)
1436
+ Modules/_functoolsmodule.o: $(srcdir)/Modules/_functoolsmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/_functoolsmodule.c -o Modules/_functoolsmodule.o
1437
+ Modules/_functoolsmodule$(SO): Modules/_functoolsmodule.o; $(BLDSHARED) Modules/_functoolsmodule.o -o Modules/_functoolsmodule$(SO)
1438
+ Modules/_bisectmodule.o: $(srcdir)/Modules/_bisectmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/_bisectmodule.c -o Modules/_bisectmodule.o
1439
+ Modules/_bisectmodule$(SO): Modules/_bisectmodule.o; $(BLDSHARED) Modules/_bisectmodule.o -o Modules/_bisectmodule$(SO)
1440
+ Modules/unicodedata.o: $(srcdir)/Modules/unicodedata.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/unicodedata.c -o Modules/unicodedata.o
1441
+ Modules/unicodedata$(SO): Modules/unicodedata.o; $(BLDSHARED) Modules/unicodedata.o -o Modules/unicodedata$(SO)
1442
+ Modules/_localemodule.o: $(srcdir)/Modules/_localemodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/_localemodule.c -o Modules/_localemodule.o
1443
+ Modules/_localemodule$(SO): Modules/_localemodule.o; $(BLDSHARED) Modules/_localemodule.o -o Modules/_localemodule$(SO)
1444
+ Modules/bufferedio.o: $(srcdir)/Modules/_io/bufferedio.c; $(CC) $(PY_CORE_CFLAGS) -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/bufferedio.c -o Modules/bufferedio.o
1445
+ Modules/bytesio.o: $(srcdir)/Modules/_io/bytesio.c; $(CC) $(PY_CORE_CFLAGS) -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/bytesio.c -o Modules/bytesio.o
1446
+ Modules/fileio.o: $(srcdir)/Modules/_io/fileio.c; $(CC) $(PY_CORE_CFLAGS) -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/fileio.c -o Modules/fileio.o
1447
+ Modules/iobase.o: $(srcdir)/Modules/_io/iobase.c; $(CC) $(PY_CORE_CFLAGS) -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/iobase.c -o Modules/iobase.o
1448
+ Modules/_iomodule.o: $(srcdir)/Modules/_io/_iomodule.c; $(CC) $(PY_CORE_CFLAGS) -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/_iomodule.c -o Modules/_iomodule.o
1449
+ Modules/stringio.o: $(srcdir)/Modules/_io/stringio.c; $(CC) $(PY_CORE_CFLAGS) -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/stringio.c -o Modules/stringio.o
1450
+ Modules/textio.o: $(srcdir)/Modules/_io/textio.c; $(CC) $(PY_CORE_CFLAGS) -I$(srcdir)/Modules/_io -c $(srcdir)/Modules/_io/textio.c -o Modules/textio.o
1451
+ Modules/_iomodule$(SO): Modules/bufferedio.o Modules/bytesio.o Modules/fileio.o Modules/iobase.o Modules/_iomodule.o Modules/stringio.o Modules/textio.o; $(BLDSHARED) Modules/bufferedio.o Modules/bytesio.o Modules/fileio.o Modules/iobase.o Modules/_iomodule.o Modules/stringio.o Modules/textio.o -o Modules/_iomodule$(SO)
1452
+ Modules/fcntlmodule.o: $(srcdir)/Modules/fcntlmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/fcntlmodule.c -o Modules/fcntlmodule.o
1453
+ Modules/fcntlmodule$(SO): Modules/fcntlmodule.o; $(BLDSHARED) Modules/fcntlmodule.o -o Modules/fcntlmodule$(SO)
1454
+ Modules/spwdmodule.o: $(srcdir)/Modules/spwdmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/spwdmodule.c -o Modules/spwdmodule.o
1455
+ Modules/spwdmodule$(SO): Modules/spwdmodule.o; $(BLDSHARED) Modules/spwdmodule.o -o Modules/spwdmodule$(SO)
1456
+ Modules/grpmodule.o: $(srcdir)/Modules/grpmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/grpmodule.c -o Modules/grpmodule.o
1457
+ Modules/grpmodule$(SO): Modules/grpmodule.o; $(BLDSHARED) Modules/grpmodule.o -o Modules/grpmodule$(SO)
1458
+ Modules/selectmodule.o: $(srcdir)/Modules/selectmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/selectmodule.c -o Modules/selectmodule.o
1459
+ Modules/selectmodule$(SO): Modules/selectmodule.o; $(BLDSHARED) Modules/selectmodule.o -o Modules/selectmodule$(SO)
1460
+ Modules/socketmodule.o: $(srcdir)/Modules/socketmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/socketmodule.c -o Modules/socketmodule.o
1461
+ Modules/timemodule.o: $(srcdir)/Modules/timemodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/timemodule.c -o Modules/timemodule.o
1462
+ Modules/_socketmodule$(SO): Modules/socketmodule.o Modules/timemodule.o; $(BLDSHARED) Modules/socketmodule.o Modules/timemodule.o -o Modules/_socketmodule$(SO)
1463
+ Modules/md5module.o: $(srcdir)/Modules/md5module.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/md5module.c -o Modules/md5module.o
1464
+ Modules/md5.o: $(srcdir)/Modules/md5.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/md5.c -o Modules/md5.o
1465
+ Modules/_md5module$(SO): Modules/md5module.o Modules/md5.o; $(BLDSHARED) Modules/md5module.o Modules/md5.o -o Modules/_md5module$(SO)
1466
+ Modules/shamodule.o: $(srcdir)/Modules/shamodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/shamodule.c -o Modules/shamodule.o
1467
+ Modules/_shamodule$(SO): Modules/shamodule.o; $(BLDSHARED) Modules/shamodule.o -o Modules/_shamodule$(SO)
1468
+ Modules/sha256module.o: $(srcdir)/Modules/sha256module.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/sha256module.c -o Modules/sha256module.o
1469
+ Modules/_sha256module$(SO): Modules/sha256module.o; $(BLDSHARED) Modules/sha256module.o -o Modules/_sha256module$(SO)
1470
+ Modules/sha512module.o: $(srcdir)/Modules/sha512module.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/sha512module.c -o Modules/sha512module.o
1471
+ Modules/_sha512module$(SO): Modules/sha512module.o; $(BLDSHARED) Modules/sha512module.o -o Modules/_sha512module$(SO)
1472
+ Modules/syslogmodule.o: $(srcdir)/Modules/syslogmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/syslogmodule.c -o Modules/syslogmodule.o
1473
+ Modules/syslogmodule$(SO): Modules/syslogmodule.o; $(BLDSHARED) Modules/syslogmodule.o -o Modules/syslogmodule$(SO)
1474
+ Modules/binascii.o: $(srcdir)/Modules/binascii.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/binascii.c -o Modules/binascii.o
1475
+ Modules/binascii$(SO): Modules/binascii.o; $(BLDSHARED) Modules/binascii.o -o Modules/binascii$(SO)
1476
+ Modules/cStringIO.o: $(srcdir)/Modules/cStringIO.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/cStringIO.c -o Modules/cStringIO.o
1477
+ Modules/cStringIO$(SO): Modules/cStringIO.o; $(BLDSHARED) Modules/cStringIO.o -o Modules/cStringIO$(SO)
1478
+ Modules/cPickle.o: $(srcdir)/Modules/cPickle.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/cPickle.c -o Modules/cPickle.o
1479
+ Modules/cPickle$(SO): Modules/cPickle.o; $(BLDSHARED) Modules/cPickle.o -o Modules/cPickle$(SO)
1480
+ Modules/zlibmodule.o: $(srcdir)/Modules/zlibmodule.c; $(CC) $(PY_CORE_CFLAGS) -I$(prefix)/include -c $(srcdir)/Modules/zlibmodule.c -o Modules/zlibmodule.o
1481
+ Modules/zlibmodule$(SO): Modules/zlibmodule.o; $(BLDSHARED) Modules/zlibmodule.o -L$(exec_prefix)/lib -lz -o Modules/zlibmodule$(SO)
1482
+ Modules/posixmodule.o: $(srcdir)/Modules/posixmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/posixmodule.c -o Modules/posixmodule.o
1483
+ Modules/posixmodule$(SO): Modules/posixmodule.o; $(BLDSHARED) Modules/posixmodule.o -o Modules/posixmodule$(SO)
1484
+ Modules/errnomodule.o: $(srcdir)/Modules/errnomodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/errnomodule.c -o Modules/errnomodule.o
1485
+ Modules/errnomodule$(SO): Modules/errnomodule.o; $(BLDSHARED) Modules/errnomodule.o -o Modules/errnomodule$(SO)
1486
+ Modules/pwdmodule.o: $(srcdir)/Modules/pwdmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/pwdmodule.c -o Modules/pwdmodule.o
1487
+ Modules/pwdmodule$(SO): Modules/pwdmodule.o; $(BLDSHARED) Modules/pwdmodule.o -o Modules/pwdmodule$(SO)
1488
+ Modules/_sre.o: $(srcdir)/Modules/_sre.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/_sre.c -o Modules/_sre.o
1489
+ Modules/_sre$(SO): Modules/_sre.o; $(BLDSHARED) Modules/_sre.o -o Modules/_sre$(SO)
1490
+ Modules/_codecsmodule.o: $(srcdir)/Modules/_codecsmodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/_codecsmodule.c -o Modules/_codecsmodule.o
1491
+ Modules/_codecsmodule$(SO): Modules/_codecsmodule.o; $(BLDSHARED) Modules/_codecsmodule.o -o Modules/_codecsmodule$(SO)
1492
+ Modules/_weakref.o: $(srcdir)/Modules/_weakref.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/_weakref.c -o Modules/_weakref.o
1493
+ Modules/_weakref$(SO): Modules/_weakref.o; $(BLDSHARED) Modules/_weakref.o -o Modules/_weakref$(SO)
1494
+ Modules/zipimport.o: $(srcdir)/Modules/zipimport.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/zipimport.c -o Modules/zipimport.o
1495
+ Modules/zipimport$(SO): Modules/zipimport.o; $(BLDSHARED) Modules/zipimport.o -o Modules/zipimport$(SO)
1496
+ Modules/symtablemodule.o: $(srcdir)/Modules/symtablemodule.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/symtablemodule.c -o Modules/symtablemodule.o
1497
+ Modules/_symtablemodule$(SO): Modules/symtablemodule.o; $(BLDSHARED) Modules/symtablemodule.o -o Modules/_symtablemodule$(SO)
1498
+ Modules/xxsubtype.o: $(srcdir)/Modules/xxsubtype.c; $(CC) $(PY_CORE_CFLAGS) -c $(srcdir)/Modules/xxsubtype.c -o Modules/xxsubtype.o
1499
+ Modules/xxsubtype$(SO): Modules/xxsubtype.o; $(BLDSHARED) Modules/xxsubtype.o -o Modules/xxsubtype$(SO)
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ #empty
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/__main__.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ import sys
2
+ from .main import main
3
+
4
+ sys.exit(main("lib2to3.fixes"))
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/btm_matcher.py ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """A bottom-up tree matching algorithm implementation meant to speed
2
+ up 2to3's matching process. After the tree patterns are reduced to
3
+ their rarest linear path, a linear Aho-Corasick automaton is
4
+ created. The linear automaton traverses the linear paths from the
5
+ leaves to the root of the AST and returns a set of nodes for further
6
+ matching. This reduces significantly the number of candidate nodes."""
7
+
8
+ __author__ = "George Boutsioukis <gboutsioukis@gmail.com>"
9
+
10
+ import logging
11
+ import itertools
12
+ from collections import defaultdict
13
+
14
+ from . import pytree
15
+ from .btm_utils import reduce_tree
16
+
17
+ class BMNode(object):
18
+ """Class for a node of the Aho-Corasick automaton used in matching"""
19
+ count = itertools.count()
20
+ def __init__(self):
21
+ self.transition_table = {}
22
+ self.fixers = []
23
+ self.id = next(BMNode.count)
24
+ self.content = ''
25
+
26
+ class BottomMatcher(object):
27
+ """The main matcher class. After instantiating the patterns should
28
+ be added using the add_fixer method"""
29
+
30
+ def __init__(self):
31
+ self.match = set()
32
+ self.root = BMNode()
33
+ self.nodes = [self.root]
34
+ self.fixers = []
35
+ self.logger = logging.getLogger("RefactoringTool")
36
+
37
+ def add_fixer(self, fixer):
38
+ """Reduces a fixer's pattern tree to a linear path and adds it
39
+ to the matcher(a common Aho-Corasick automaton). The fixer is
40
+ appended on the matching states and called when they are
41
+ reached"""
42
+ self.fixers.append(fixer)
43
+ tree = reduce_tree(fixer.pattern_tree)
44
+ linear = tree.get_linear_subpattern()
45
+ match_nodes = self.add(linear, start=self.root)
46
+ for match_node in match_nodes:
47
+ match_node.fixers.append(fixer)
48
+
49
+ def add(self, pattern, start):
50
+ "Recursively adds a linear pattern to the AC automaton"
51
+ #print("adding pattern", pattern, "to", start)
52
+ if not pattern:
53
+ #print("empty pattern")
54
+ return [start]
55
+ if isinstance(pattern[0], tuple):
56
+ #alternatives
57
+ #print("alternatives")
58
+ match_nodes = []
59
+ for alternative in pattern[0]:
60
+ #add all alternatives, and add the rest of the pattern
61
+ #to each end node
62
+ end_nodes = self.add(alternative, start=start)
63
+ for end in end_nodes:
64
+ match_nodes.extend(self.add(pattern[1:], end))
65
+ return match_nodes
66
+ else:
67
+ #single token
68
+ #not last
69
+ if pattern[0] not in start.transition_table:
70
+ #transition did not exist, create new
71
+ next_node = BMNode()
72
+ start.transition_table[pattern[0]] = next_node
73
+ else:
74
+ #transition exists already, follow
75
+ next_node = start.transition_table[pattern[0]]
76
+
77
+ if pattern[1:]:
78
+ end_nodes = self.add(pattern[1:], start=next_node)
79
+ else:
80
+ end_nodes = [next_node]
81
+ return end_nodes
82
+
83
+ def run(self, leaves):
84
+ """The main interface with the bottom matcher. The tree is
85
+ traversed from the bottom using the constructed
86
+ automaton. Nodes are only checked once as the tree is
87
+ retraversed. When the automaton fails, we give it one more
88
+ shot(in case the above tree matches as a whole with the
89
+ rejected leaf), then we break for the next leaf. There is the
90
+ special case of multiple arguments(see code comments) where we
91
+ recheck the nodes
92
+
93
+ Args:
94
+ The leaves of the AST tree to be matched
95
+
96
+ Returns:
97
+ A dictionary of node matches with fixers as the keys
98
+ """
99
+ current_ac_node = self.root
100
+ results = defaultdict(list)
101
+ for leaf in leaves:
102
+ current_ast_node = leaf
103
+ while current_ast_node:
104
+ current_ast_node.was_checked = True
105
+ for child in current_ast_node.children:
106
+ # multiple statements, recheck
107
+ if isinstance(child, pytree.Leaf) and child.value == u";":
108
+ current_ast_node.was_checked = False
109
+ break
110
+ if current_ast_node.type == 1:
111
+ #name
112
+ node_token = current_ast_node.value
113
+ else:
114
+ node_token = current_ast_node.type
115
+
116
+ if node_token in current_ac_node.transition_table:
117
+ #token matches
118
+ current_ac_node = current_ac_node.transition_table[node_token]
119
+ for fixer in current_ac_node.fixers:
120
+ if not fixer in results:
121
+ results[fixer] = []
122
+ results[fixer].append(current_ast_node)
123
+
124
+ else:
125
+ #matching failed, reset automaton
126
+ current_ac_node = self.root
127
+ if (current_ast_node.parent is not None
128
+ and current_ast_node.parent.was_checked):
129
+ #the rest of the tree upwards has been checked, next leaf
130
+ break
131
+
132
+ #recheck the rejected node once from the root
133
+ if node_token in current_ac_node.transition_table:
134
+ #token matches
135
+ current_ac_node = current_ac_node.transition_table[node_token]
136
+ for fixer in current_ac_node.fixers:
137
+ if not fixer in results.keys():
138
+ results[fixer] = []
139
+ results[fixer].append(current_ast_node)
140
+
141
+ current_ast_node = current_ast_node.parent
142
+ return results
143
+
144
+ def print_ac(self):
145
+ "Prints a graphviz diagram of the BM automaton(for debugging)"
146
+ print("digraph g{")
147
+ def print_node(node):
148
+ for subnode_key in node.transition_table.keys():
149
+ subnode = node.transition_table[subnode_key]
150
+ print("%d -> %d [label=%s] //%s" %
151
+ (node.id, subnode.id, type_repr(subnode_key), str(subnode.fixers)))
152
+ if subnode_key == 1:
153
+ print(subnode.content)
154
+ print_node(subnode)
155
+ print_node(self.root)
156
+ print("}")
157
+
158
+ # taken from pytree.py for debugging; only used by print_ac
159
+ _type_reprs = {}
160
+ def type_repr(type_num):
161
+ global _type_reprs
162
+ if not _type_reprs:
163
+ from .pygram import python_symbols
164
+ # printing tokens is possible but not as useful
165
+ # from .pgen2 import token // token.__dict__.items():
166
+ for name, val in python_symbols.__dict__.items():
167
+ if type(val) == int: _type_reprs[val] = name
168
+ return _type_reprs.setdefault(type_num, type_num)
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/btm_utils.py ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Utility functions used by the btm_matcher module"
2
+
3
+ from . import pytree
4
+ from .pgen2 import grammar, token
5
+ from .pygram import pattern_symbols, python_symbols
6
+
7
+ syms = pattern_symbols
8
+ pysyms = python_symbols
9
+ tokens = grammar.opmap
10
+ token_labels = token
11
+
12
+ TYPE_ANY = -1
13
+ TYPE_ALTERNATIVES = -2
14
+ TYPE_GROUP = -3
15
+
16
+ class MinNode(object):
17
+ """This class serves as an intermediate representation of the
18
+ pattern tree during the conversion to sets of leaf-to-root
19
+ subpatterns"""
20
+
21
+ def __init__(self, type=None, name=None):
22
+ self.type = type
23
+ self.name = name
24
+ self.children = []
25
+ self.leaf = False
26
+ self.parent = None
27
+ self.alternatives = []
28
+ self.group = []
29
+
30
+ def __repr__(self):
31
+ return str(self.type) + ' ' + str(self.name)
32
+
33
+ def leaf_to_root(self):
34
+ """Internal method. Returns a characteristic path of the
35
+ pattern tree. This method must be run for all leaves until the
36
+ linear subpatterns are merged into a single"""
37
+ node = self
38
+ subp = []
39
+ while node:
40
+ if node.type == TYPE_ALTERNATIVES:
41
+ node.alternatives.append(subp)
42
+ if len(node.alternatives) == len(node.children):
43
+ #last alternative
44
+ subp = [tuple(node.alternatives)]
45
+ node.alternatives = []
46
+ node = node.parent
47
+ continue
48
+ else:
49
+ node = node.parent
50
+ subp = None
51
+ break
52
+
53
+ if node.type == TYPE_GROUP:
54
+ node.group.append(subp)
55
+ #probably should check the number of leaves
56
+ if len(node.group) == len(node.children):
57
+ subp = get_characteristic_subpattern(node.group)
58
+ node.group = []
59
+ node = node.parent
60
+ continue
61
+ else:
62
+ node = node.parent
63
+ subp = None
64
+ break
65
+
66
+ if node.type == token_labels.NAME and node.name:
67
+ #in case of type=name, use the name instead
68
+ subp.append(node.name)
69
+ else:
70
+ subp.append(node.type)
71
+
72
+ node = node.parent
73
+ return subp
74
+
75
+ def get_linear_subpattern(self):
76
+ """Drives the leaf_to_root method. The reason that
77
+ leaf_to_root must be run multiple times is because we need to
78
+ reject 'group' matches; for example the alternative form
79
+ (a | b c) creates a group [b c] that needs to be matched. Since
80
+ matching multiple linear patterns overcomes the automaton's
81
+ capabilities, leaf_to_root merges each group into a single
82
+ choice based on 'characteristic'ity,
83
+
84
+ i.e. (a|b c) -> (a|b) if b more characteristic than c
85
+
86
+ Returns: The most 'characteristic'(as defined by
87
+ get_characteristic_subpattern) path for the compiled pattern
88
+ tree.
89
+ """
90
+
91
+ for l in self.leaves():
92
+ subp = l.leaf_to_root()
93
+ if subp:
94
+ return subp
95
+
96
+ def leaves(self):
97
+ "Generator that returns the leaves of the tree"
98
+ for child in self.children:
99
+ for x in child.leaves():
100
+ yield x
101
+ if not self.children:
102
+ yield self
103
+
104
+ def reduce_tree(node, parent=None):
105
+ """
106
+ Internal function. Reduces a compiled pattern tree to an
107
+ intermediate representation suitable for feeding the
108
+ automaton. This also trims off any optional pattern elements(like
109
+ [a], a*).
110
+ """
111
+
112
+ new_node = None
113
+ #switch on the node type
114
+ if node.type == syms.Matcher:
115
+ #skip
116
+ node = node.children[0]
117
+
118
+ if node.type == syms.Alternatives :
119
+ #2 cases
120
+ if len(node.children) <= 2:
121
+ #just a single 'Alternative', skip this node
122
+ new_node = reduce_tree(node.children[0], parent)
123
+ else:
124
+ #real alternatives
125
+ new_node = MinNode(type=TYPE_ALTERNATIVES)
126
+ #skip odd children('|' tokens)
127
+ for child in node.children:
128
+ if node.children.index(child)%2:
129
+ continue
130
+ reduced = reduce_tree(child, new_node)
131
+ if reduced is not None:
132
+ new_node.children.append(reduced)
133
+ elif node.type == syms.Alternative:
134
+ if len(node.children) > 1:
135
+
136
+ new_node = MinNode(type=TYPE_GROUP)
137
+ for child in node.children:
138
+ reduced = reduce_tree(child, new_node)
139
+ if reduced:
140
+ new_node.children.append(reduced)
141
+ if not new_node.children:
142
+ # delete the group if all of the children were reduced to None
143
+ new_node = None
144
+
145
+ else:
146
+ new_node = reduce_tree(node.children[0], parent)
147
+
148
+ elif node.type == syms.Unit:
149
+ if (isinstance(node.children[0], pytree.Leaf) and
150
+ node.children[0].value == '('):
151
+ #skip parentheses
152
+ return reduce_tree(node.children[1], parent)
153
+ if ((isinstance(node.children[0], pytree.Leaf) and
154
+ node.children[0].value == '[')
155
+ or
156
+ (len(node.children)>1 and
157
+ hasattr(node.children[1], "value") and
158
+ node.children[1].value == '[')):
159
+ #skip whole unit if its optional
160
+ return None
161
+
162
+ leaf = True
163
+ details_node = None
164
+ alternatives_node = None
165
+ has_repeater = False
166
+ repeater_node = None
167
+ has_variable_name = False
168
+
169
+ for child in node.children:
170
+ if child.type == syms.Details:
171
+ leaf = False
172
+ details_node = child
173
+ elif child.type == syms.Repeater:
174
+ has_repeater = True
175
+ repeater_node = child
176
+ elif child.type == syms.Alternatives:
177
+ alternatives_node = child
178
+ if hasattr(child, 'value') and child.value == '=': # variable name
179
+ has_variable_name = True
180
+
181
+ #skip variable name
182
+ if has_variable_name:
183
+ #skip variable name, '='
184
+ name_leaf = node.children[2]
185
+ if hasattr(name_leaf, 'value') and name_leaf.value == '(':
186
+ # skip parenthesis
187
+ name_leaf = node.children[3]
188
+ else:
189
+ name_leaf = node.children[0]
190
+
191
+ #set node type
192
+ if name_leaf.type == token_labels.NAME:
193
+ #(python) non-name or wildcard
194
+ if name_leaf.value == 'any':
195
+ new_node = MinNode(type=TYPE_ANY)
196
+ else:
197
+ if hasattr(token_labels, name_leaf.value):
198
+ new_node = MinNode(type=getattr(token_labels, name_leaf.value))
199
+ else:
200
+ new_node = MinNode(type=getattr(pysyms, name_leaf.value))
201
+
202
+ elif name_leaf.type == token_labels.STRING:
203
+ #(python) name or character; remove the apostrophes from
204
+ #the string value
205
+ name = name_leaf.value.strip("'")
206
+ if name in tokens:
207
+ new_node = MinNode(type=tokens[name])
208
+ else:
209
+ new_node = MinNode(type=token_labels.NAME, name=name)
210
+ elif name_leaf.type == syms.Alternatives:
211
+ new_node = reduce_tree(alternatives_node, parent)
212
+
213
+ #handle repeaters
214
+ if has_repeater:
215
+ if repeater_node.children[0].value == '*':
216
+ #reduce to None
217
+ new_node = None
218
+ elif repeater_node.children[0].value == '+':
219
+ #reduce to a single occurence i.e. do nothing
220
+ pass
221
+ else:
222
+ #TODO: handle {min, max} repeaters
223
+ raise NotImplementedError
224
+ pass
225
+
226
+ #add children
227
+ if details_node and new_node is not None:
228
+ for child in details_node.children[1:-1]:
229
+ #skip '<', '>' markers
230
+ reduced = reduce_tree(child, new_node)
231
+ if reduced is not None:
232
+ new_node.children.append(reduced)
233
+ if new_node:
234
+ new_node.parent = parent
235
+ return new_node
236
+
237
+
238
+ def get_characteristic_subpattern(subpatterns):
239
+ """Picks the most characteristic from a list of linear patterns
240
+ Current order used is:
241
+ names > common_names > common_chars
242
+ """
243
+ if not isinstance(subpatterns, list):
244
+ return subpatterns
245
+ if len(subpatterns)==1:
246
+ return subpatterns[0]
247
+
248
+ # first pick out the ones containing variable names
249
+ subpatterns_with_names = []
250
+ subpatterns_with_common_names = []
251
+ common_names = ['in', 'for', 'if' , 'not', 'None']
252
+ subpatterns_with_common_chars = []
253
+ common_chars = "[]().,:"
254
+ for subpattern in subpatterns:
255
+ if any(rec_test(subpattern, lambda x: type(x) is str)):
256
+ if any(rec_test(subpattern,
257
+ lambda x: isinstance(x, str) and x in common_chars)):
258
+ subpatterns_with_common_chars.append(subpattern)
259
+ elif any(rec_test(subpattern,
260
+ lambda x: isinstance(x, str) and x in common_names)):
261
+ subpatterns_with_common_names.append(subpattern)
262
+
263
+ else:
264
+ subpatterns_with_names.append(subpattern)
265
+
266
+ if subpatterns_with_names:
267
+ subpatterns = subpatterns_with_names
268
+ elif subpatterns_with_common_names:
269
+ subpatterns = subpatterns_with_common_names
270
+ elif subpatterns_with_common_chars:
271
+ subpatterns = subpatterns_with_common_chars
272
+ # of the remaining subpatterns pick out the longest one
273
+ return max(subpatterns, key=len)
274
+
275
+ def rec_test(sequence, test_func):
276
+ """Tests test_func on all items of sequence and items of included
277
+ sub-iterables"""
278
+ for x in sequence:
279
+ if isinstance(x, (list, tuple)):
280
+ for y in rec_test(x, test_func):
281
+ yield y
282
+ else:
283
+ yield test_func(x)
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixer_base.py ADDED
@@ -0,0 +1,189 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2006 Google, Inc. All Rights Reserved.
2
+ # Licensed to PSF under a Contributor Agreement.
3
+
4
+ """Base class for fixers (optional, but recommended)."""
5
+
6
+ # Python imports
7
+ import logging
8
+ import itertools
9
+
10
+ # Local imports
11
+ from .patcomp import PatternCompiler
12
+ from . import pygram
13
+ from .fixer_util import does_tree_import
14
+
15
+ class BaseFix(object):
16
+
17
+ """Optional base class for fixers.
18
+
19
+ The subclass name must be FixFooBar where FooBar is the result of
20
+ removing underscores and capitalizing the words of the fix name.
21
+ For example, the class name for a fixer named 'has_key' should be
22
+ FixHasKey.
23
+ """
24
+
25
+ PATTERN = None # Most subclasses should override with a string literal
26
+ pattern = None # Compiled pattern, set by compile_pattern()
27
+ pattern_tree = None # Tree representation of the pattern
28
+ options = None # Options object passed to initializer
29
+ filename = None # The filename (set by set_filename)
30
+ logger = None # A logger (set by set_filename)
31
+ numbers = itertools.count(1) # For new_name()
32
+ used_names = set() # A set of all used NAMEs
33
+ order = "post" # Does the fixer prefer pre- or post-order traversal
34
+ explicit = False # Is this ignored by refactor.py -f all?
35
+ run_order = 5 # Fixers will be sorted by run order before execution
36
+ # Lower numbers will be run first.
37
+ _accept_type = None # [Advanced and not public] This tells RefactoringTool
38
+ # which node type to accept when there's not a pattern.
39
+
40
+ keep_line_order = False # For the bottom matcher: match with the
41
+ # original line order
42
+ BM_compatible = False # Compatibility with the bottom matching
43
+ # module; every fixer should set this
44
+ # manually
45
+
46
+ # Shortcut for access to Python grammar symbols
47
+ syms = pygram.python_symbols
48
+
49
+ def __init__(self, options, log):
50
+ """Initializer. Subclass may override.
51
+
52
+ Args:
53
+ options: an dict containing the options passed to RefactoringTool
54
+ that could be used to customize the fixer through the command line.
55
+ log: a list to append warnings and other messages to.
56
+ """
57
+ self.options = options
58
+ self.log = log
59
+ self.compile_pattern()
60
+
61
+ def compile_pattern(self):
62
+ """Compiles self.PATTERN into self.pattern.
63
+
64
+ Subclass may override if it doesn't want to use
65
+ self.{pattern,PATTERN} in .match().
66
+ """
67
+ if self.PATTERN is not None:
68
+ PC = PatternCompiler()
69
+ self.pattern, self.pattern_tree = PC.compile_pattern(self.PATTERN,
70
+ with_tree=True)
71
+
72
+ def set_filename(self, filename):
73
+ """Set the filename, and a logger derived from it.
74
+
75
+ The main refactoring tool should call this.
76
+ """
77
+ self.filename = filename
78
+ self.logger = logging.getLogger(filename)
79
+
80
+ def match(self, node):
81
+ """Returns match for a given parse tree node.
82
+
83
+ Should return a true or false object (not necessarily a bool).
84
+ It may return a non-empty dict of matching sub-nodes as
85
+ returned by a matching pattern.
86
+
87
+ Subclass may override.
88
+ """
89
+ results = {"node": node}
90
+ return self.pattern.match(node, results) and results
91
+
92
+ def transform(self, node, results):
93
+ """Returns the transformation for a given parse tree node.
94
+
95
+ Args:
96
+ node: the root of the parse tree that matched the fixer.
97
+ results: a dict mapping symbolic names to part of the match.
98
+
99
+ Returns:
100
+ None, or a node that is a modified copy of the
101
+ argument node. The node argument may also be modified in-place to
102
+ effect the same change.
103
+
104
+ Subclass *must* override.
105
+ """
106
+ raise NotImplementedError()
107
+
108
+ def new_name(self, template=u"xxx_todo_changeme"):
109
+ """Return a string suitable for use as an identifier
110
+
111
+ The new name is guaranteed not to conflict with other identifiers.
112
+ """
113
+ name = template
114
+ while name in self.used_names:
115
+ name = template + unicode(self.numbers.next())
116
+ self.used_names.add(name)
117
+ return name
118
+
119
+ def log_message(self, message):
120
+ if self.first_log:
121
+ self.first_log = False
122
+ self.log.append("### In file %s ###" % self.filename)
123
+ self.log.append(message)
124
+
125
+ def cannot_convert(self, node, reason=None):
126
+ """Warn the user that a given chunk of code is not valid Python 3,
127
+ but that it cannot be converted automatically.
128
+
129
+ First argument is the top-level node for the code in question.
130
+ Optional second argument is why it can't be converted.
131
+ """
132
+ lineno = node.get_lineno()
133
+ for_output = node.clone()
134
+ for_output.prefix = u""
135
+ msg = "Line %d: could not convert: %s"
136
+ self.log_message(msg % (lineno, for_output))
137
+ if reason:
138
+ self.log_message(reason)
139
+
140
+ def warning(self, node, reason):
141
+ """Used for warning the user about possible uncertainty in the
142
+ translation.
143
+
144
+ First argument is the top-level node for the code in question.
145
+ Optional second argument is why it can't be converted.
146
+ """
147
+ lineno = node.get_lineno()
148
+ self.log_message("Line %d: %s" % (lineno, reason))
149
+
150
+ def start_tree(self, tree, filename):
151
+ """Some fixers need to maintain tree-wide state.
152
+ This method is called once, at the start of tree fix-up.
153
+
154
+ tree - the root node of the tree to be processed.
155
+ filename - the name of the file the tree came from.
156
+ """
157
+ self.used_names = tree.used_names
158
+ self.set_filename(filename)
159
+ self.numbers = itertools.count(1)
160
+ self.first_log = True
161
+
162
+ def finish_tree(self, tree, filename):
163
+ """Some fixers need to maintain tree-wide state.
164
+ This method is called once, at the conclusion of tree fix-up.
165
+
166
+ tree - the root node of the tree to be processed.
167
+ filename - the name of the file the tree came from.
168
+ """
169
+ pass
170
+
171
+
172
+ class ConditionalFix(BaseFix):
173
+ """ Base class for fixers which not execute if an import is found. """
174
+
175
+ # This is the name of the import which, if found, will cause the test to be skipped
176
+ skip_on = None
177
+
178
+ def start_tree(self, *args):
179
+ super(ConditionalFix, self).start_tree(*args)
180
+ self._should_skip = None
181
+
182
+ def should_skip(self, node):
183
+ if self._should_skip is not None:
184
+ return self._should_skip
185
+ pkg = self.skip_on.split(".")
186
+ name = pkg[-1]
187
+ pkg = ".".join(pkg[:-1])
188
+ self._should_skip = does_tree_import(pkg, name, node)
189
+ return self._should_skip
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixer_util.py ADDED
@@ -0,0 +1,432 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Utility functions, node construction macros, etc."""
2
+ # Author: Collin Winter
3
+
4
+ from itertools import islice
5
+
6
+ # Local imports
7
+ from .pgen2 import token
8
+ from .pytree import Leaf, Node
9
+ from .pygram import python_symbols as syms
10
+ from . import patcomp
11
+
12
+
13
+ ###########################################################
14
+ ### Common node-construction "macros"
15
+ ###########################################################
16
+
17
+ def KeywordArg(keyword, value):
18
+ return Node(syms.argument,
19
+ [keyword, Leaf(token.EQUAL, u"="), value])
20
+
21
+ def LParen():
22
+ return Leaf(token.LPAR, u"(")
23
+
24
+ def RParen():
25
+ return Leaf(token.RPAR, u")")
26
+
27
+ def Assign(target, source):
28
+ """Build an assignment statement"""
29
+ if not isinstance(target, list):
30
+ target = [target]
31
+ if not isinstance(source, list):
32
+ source.prefix = u" "
33
+ source = [source]
34
+
35
+ return Node(syms.atom,
36
+ target + [Leaf(token.EQUAL, u"=", prefix=u" ")] + source)
37
+
38
+ def Name(name, prefix=None):
39
+ """Return a NAME leaf"""
40
+ return Leaf(token.NAME, name, prefix=prefix)
41
+
42
+ def Attr(obj, attr):
43
+ """A node tuple for obj.attr"""
44
+ return [obj, Node(syms.trailer, [Dot(), attr])]
45
+
46
+ def Comma():
47
+ """A comma leaf"""
48
+ return Leaf(token.COMMA, u",")
49
+
50
+ def Dot():
51
+ """A period (.) leaf"""
52
+ return Leaf(token.DOT, u".")
53
+
54
+ def ArgList(args, lparen=LParen(), rparen=RParen()):
55
+ """A parenthesised argument list, used by Call()"""
56
+ node = Node(syms.trailer, [lparen.clone(), rparen.clone()])
57
+ if args:
58
+ node.insert_child(1, Node(syms.arglist, args))
59
+ return node
60
+
61
+ def Call(func_name, args=None, prefix=None):
62
+ """A function call"""
63
+ node = Node(syms.power, [func_name, ArgList(args)])
64
+ if prefix is not None:
65
+ node.prefix = prefix
66
+ return node
67
+
68
+ def Newline():
69
+ """A newline literal"""
70
+ return Leaf(token.NEWLINE, u"\n")
71
+
72
+ def BlankLine():
73
+ """A blank line"""
74
+ return Leaf(token.NEWLINE, u"")
75
+
76
+ def Number(n, prefix=None):
77
+ return Leaf(token.NUMBER, n, prefix=prefix)
78
+
79
+ def Subscript(index_node):
80
+ """A numeric or string subscript"""
81
+ return Node(syms.trailer, [Leaf(token.LBRACE, u"["),
82
+ index_node,
83
+ Leaf(token.RBRACE, u"]")])
84
+
85
+ def String(string, prefix=None):
86
+ """A string leaf"""
87
+ return Leaf(token.STRING, string, prefix=prefix)
88
+
89
+ def ListComp(xp, fp, it, test=None):
90
+ """A list comprehension of the form [xp for fp in it if test].
91
+
92
+ If test is None, the "if test" part is omitted.
93
+ """
94
+ xp.prefix = u""
95
+ fp.prefix = u" "
96
+ it.prefix = u" "
97
+ for_leaf = Leaf(token.NAME, u"for")
98
+ for_leaf.prefix = u" "
99
+ in_leaf = Leaf(token.NAME, u"in")
100
+ in_leaf.prefix = u" "
101
+ inner_args = [for_leaf, fp, in_leaf, it]
102
+ if test:
103
+ test.prefix = u" "
104
+ if_leaf = Leaf(token.NAME, u"if")
105
+ if_leaf.prefix = u" "
106
+ inner_args.append(Node(syms.comp_if, [if_leaf, test]))
107
+ inner = Node(syms.listmaker, [xp, Node(syms.comp_for, inner_args)])
108
+ return Node(syms.atom,
109
+ [Leaf(token.LBRACE, u"["),
110
+ inner,
111
+ Leaf(token.RBRACE, u"]")])
112
+
113
+ def FromImport(package_name, name_leafs):
114
+ """ Return an import statement in the form:
115
+ from package import name_leafs"""
116
+ # XXX: May not handle dotted imports properly (eg, package_name='foo.bar')
117
+ #assert package_name == '.' or '.' not in package_name, "FromImport has "\
118
+ # "not been tested with dotted package names -- use at your own "\
119
+ # "peril!"
120
+
121
+ for leaf in name_leafs:
122
+ # Pull the leaves out of their old tree
123
+ leaf.remove()
124
+
125
+ children = [Leaf(token.NAME, u"from"),
126
+ Leaf(token.NAME, package_name, prefix=u" "),
127
+ Leaf(token.NAME, u"import", prefix=u" "),
128
+ Node(syms.import_as_names, name_leafs)]
129
+ imp = Node(syms.import_from, children)
130
+ return imp
131
+
132
+
133
+ ###########################################################
134
+ ### Determine whether a node represents a given literal
135
+ ###########################################################
136
+
137
+ def is_tuple(node):
138
+ """Does the node represent a tuple literal?"""
139
+ if isinstance(node, Node) and node.children == [LParen(), RParen()]:
140
+ return True
141
+ return (isinstance(node, Node)
142
+ and len(node.children) == 3
143
+ and isinstance(node.children[0], Leaf)
144
+ and isinstance(node.children[1], Node)
145
+ and isinstance(node.children[2], Leaf)
146
+ and node.children[0].value == u"("
147
+ and node.children[2].value == u")")
148
+
149
+ def is_list(node):
150
+ """Does the node represent a list literal?"""
151
+ return (isinstance(node, Node)
152
+ and len(node.children) > 1
153
+ and isinstance(node.children[0], Leaf)
154
+ and isinstance(node.children[-1], Leaf)
155
+ and node.children[0].value == u"["
156
+ and node.children[-1].value == u"]")
157
+
158
+
159
+ ###########################################################
160
+ ### Misc
161
+ ###########################################################
162
+
163
+ def parenthesize(node):
164
+ return Node(syms.atom, [LParen(), node, RParen()])
165
+
166
+
167
+ consuming_calls = set(["sorted", "list", "set", "any", "all", "tuple", "sum",
168
+ "min", "max", "enumerate"])
169
+
170
+ def attr_chain(obj, attr):
171
+ """Follow an attribute chain.
172
+
173
+ If you have a chain of objects where a.foo -> b, b.foo-> c, etc,
174
+ use this to iterate over all objects in the chain. Iteration is
175
+ terminated by getattr(x, attr) is None.
176
+
177
+ Args:
178
+ obj: the starting object
179
+ attr: the name of the chaining attribute
180
+
181
+ Yields:
182
+ Each successive object in the chain.
183
+ """
184
+ next = getattr(obj, attr)
185
+ while next:
186
+ yield next
187
+ next = getattr(next, attr)
188
+
189
+ p0 = """for_stmt< 'for' any 'in' node=any ':' any* >
190
+ | comp_for< 'for' any 'in' node=any any* >
191
+ """
192
+ p1 = """
193
+ power<
194
+ ( 'iter' | 'list' | 'tuple' | 'sorted' | 'set' | 'sum' |
195
+ 'any' | 'all' | 'enumerate' | (any* trailer< '.' 'join' >) )
196
+ trailer< '(' node=any ')' >
197
+ any*
198
+ >
199
+ """
200
+ p2 = """
201
+ power<
202
+ ( 'sorted' | 'enumerate' )
203
+ trailer< '(' arglist<node=any any*> ')' >
204
+ any*
205
+ >
206
+ """
207
+ pats_built = False
208
+ def in_special_context(node):
209
+ """ Returns true if node is in an environment where all that is required
210
+ of it is being iterable (ie, it doesn't matter if it returns a list
211
+ or an iterator).
212
+ See test_map_nochange in test_fixers.py for some examples and tests.
213
+ """
214
+ global p0, p1, p2, pats_built
215
+ if not pats_built:
216
+ p0 = patcomp.compile_pattern(p0)
217
+ p1 = patcomp.compile_pattern(p1)
218
+ p2 = patcomp.compile_pattern(p2)
219
+ pats_built = True
220
+ patterns = [p0, p1, p2]
221
+ for pattern, parent in zip(patterns, attr_chain(node, "parent")):
222
+ results = {}
223
+ if pattern.match(parent, results) and results["node"] is node:
224
+ return True
225
+ return False
226
+
227
+ def is_probably_builtin(node):
228
+ """
229
+ Check that something isn't an attribute or function name etc.
230
+ """
231
+ prev = node.prev_sibling
232
+ if prev is not None and prev.type == token.DOT:
233
+ # Attribute lookup.
234
+ return False
235
+ parent = node.parent
236
+ if parent.type in (syms.funcdef, syms.classdef):
237
+ return False
238
+ if parent.type == syms.expr_stmt and parent.children[0] is node:
239
+ # Assignment.
240
+ return False
241
+ if parent.type == syms.parameters or \
242
+ (parent.type == syms.typedargslist and (
243
+ (prev is not None and prev.type == token.COMMA) or
244
+ parent.children[0] is node
245
+ )):
246
+ # The name of an argument.
247
+ return False
248
+ return True
249
+
250
+ def find_indentation(node):
251
+ """Find the indentation of *node*."""
252
+ while node is not None:
253
+ if node.type == syms.suite and len(node.children) > 2:
254
+ indent = node.children[1]
255
+ if indent.type == token.INDENT:
256
+ return indent.value
257
+ node = node.parent
258
+ return u""
259
+
260
+ ###########################################################
261
+ ### The following functions are to find bindings in a suite
262
+ ###########################################################
263
+
264
+ def make_suite(node):
265
+ if node.type == syms.suite:
266
+ return node
267
+ node = node.clone()
268
+ parent, node.parent = node.parent, None
269
+ suite = Node(syms.suite, [node])
270
+ suite.parent = parent
271
+ return suite
272
+
273
+ def find_root(node):
274
+ """Find the top level namespace."""
275
+ # Scamper up to the top level namespace
276
+ while node.type != syms.file_input:
277
+ node = node.parent
278
+ if not node:
279
+ raise ValueError("root found before file_input node was found.")
280
+ return node
281
+
282
+ def does_tree_import(package, name, node):
283
+ """ Returns true if name is imported from package at the
284
+ top level of the tree which node belongs to.
285
+ To cover the case of an import like 'import foo', use
286
+ None for the package and 'foo' for the name. """
287
+ binding = find_binding(name, find_root(node), package)
288
+ return bool(binding)
289
+
290
+ def is_import(node):
291
+ """Returns true if the node is an import statement."""
292
+ return node.type in (syms.import_name, syms.import_from)
293
+
294
+ def touch_import(package, name, node):
295
+ """ Works like `does_tree_import` but adds an import statement
296
+ if it was not imported. """
297
+ def is_import_stmt(node):
298
+ return (node.type == syms.simple_stmt and node.children and
299
+ is_import(node.children[0]))
300
+
301
+ root = find_root(node)
302
+
303
+ if does_tree_import(package, name, root):
304
+ return
305
+
306
+ # figure out where to insert the new import. First try to find
307
+ # the first import and then skip to the last one.
308
+ insert_pos = offset = 0
309
+ for idx, node in enumerate(root.children):
310
+ if not is_import_stmt(node):
311
+ continue
312
+ for offset, node2 in enumerate(root.children[idx:]):
313
+ if not is_import_stmt(node2):
314
+ break
315
+ insert_pos = idx + offset
316
+ break
317
+
318
+ # if there are no imports where we can insert, find the docstring.
319
+ # if that also fails, we stick to the beginning of the file
320
+ if insert_pos == 0:
321
+ for idx, node in enumerate(root.children):
322
+ if (node.type == syms.simple_stmt and node.children and
323
+ node.children[0].type == token.STRING):
324
+ insert_pos = idx + 1
325
+ break
326
+
327
+ if package is None:
328
+ import_ = Node(syms.import_name, [
329
+ Leaf(token.NAME, u"import"),
330
+ Leaf(token.NAME, name, prefix=u" ")
331
+ ])
332
+ else:
333
+ import_ = FromImport(package, [Leaf(token.NAME, name, prefix=u" ")])
334
+
335
+ children = [import_, Newline()]
336
+ root.insert_child(insert_pos, Node(syms.simple_stmt, children))
337
+
338
+
339
+ _def_syms = set([syms.classdef, syms.funcdef])
340
+ def find_binding(name, node, package=None):
341
+ """ Returns the node which binds variable name, otherwise None.
342
+ If optional argument package is supplied, only imports will
343
+ be returned.
344
+ See test cases for examples."""
345
+ for child in node.children:
346
+ ret = None
347
+ if child.type == syms.for_stmt:
348
+ if _find(name, child.children[1]):
349
+ return child
350
+ n = find_binding(name, make_suite(child.children[-1]), package)
351
+ if n: ret = n
352
+ elif child.type in (syms.if_stmt, syms.while_stmt):
353
+ n = find_binding(name, make_suite(child.children[-1]), package)
354
+ if n: ret = n
355
+ elif child.type == syms.try_stmt:
356
+ n = find_binding(name, make_suite(child.children[2]), package)
357
+ if n:
358
+ ret = n
359
+ else:
360
+ for i, kid in enumerate(child.children[3:]):
361
+ if kid.type == token.COLON and kid.value == ":":
362
+ # i+3 is the colon, i+4 is the suite
363
+ n = find_binding(name, make_suite(child.children[i+4]), package)
364
+ if n: ret = n
365
+ elif child.type in _def_syms and child.children[1].value == name:
366
+ ret = child
367
+ elif _is_import_binding(child, name, package):
368
+ ret = child
369
+ elif child.type == syms.simple_stmt:
370
+ ret = find_binding(name, child, package)
371
+ elif child.type == syms.expr_stmt:
372
+ if _find(name, child.children[0]):
373
+ ret = child
374
+
375
+ if ret:
376
+ if not package:
377
+ return ret
378
+ if is_import(ret):
379
+ return ret
380
+ return None
381
+
382
+ _block_syms = set([syms.funcdef, syms.classdef, syms.trailer])
383
+ def _find(name, node):
384
+ nodes = [node]
385
+ while nodes:
386
+ node = nodes.pop()
387
+ if node.type > 256 and node.type not in _block_syms:
388
+ nodes.extend(node.children)
389
+ elif node.type == token.NAME and node.value == name:
390
+ return node
391
+ return None
392
+
393
+ def _is_import_binding(node, name, package=None):
394
+ """ Will reuturn node if node will import name, or node
395
+ will import * from package. None is returned otherwise.
396
+ See test cases for examples. """
397
+
398
+ if node.type == syms.import_name and not package:
399
+ imp = node.children[1]
400
+ if imp.type == syms.dotted_as_names:
401
+ for child in imp.children:
402
+ if child.type == syms.dotted_as_name:
403
+ if child.children[2].value == name:
404
+ return node
405
+ elif child.type == token.NAME and child.value == name:
406
+ return node
407
+ elif imp.type == syms.dotted_as_name:
408
+ last = imp.children[-1]
409
+ if last.type == token.NAME and last.value == name:
410
+ return node
411
+ elif imp.type == token.NAME and imp.value == name:
412
+ return node
413
+ elif node.type == syms.import_from:
414
+ # unicode(...) is used to make life easier here, because
415
+ # from a.b import parses to ['import', ['a', '.', 'b'], ...]
416
+ if package and unicode(node.children[1]).strip() != package:
417
+ return None
418
+ n = node.children[3]
419
+ if package and _find(u"as", n):
420
+ # See test_from_import_as for explanation
421
+ return None
422
+ elif n.type == syms.import_as_names and _find(name, n):
423
+ return node
424
+ elif n.type == syms.import_as_name:
425
+ child = n.children[2]
426
+ if child.type == token.NAME and child.value == name:
427
+ return node
428
+ elif n.type == token.NAME and n.value == name:
429
+ return node
430
+ elif package and n.type == token.STAR:
431
+ return node
432
+ return None
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ # Dummy file to make this directory a package.
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_apply.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2006 Google, Inc. All Rights Reserved.
2
+ # Licensed to PSF under a Contributor Agreement.
3
+
4
+ """Fixer for apply().
5
+
6
+ This converts apply(func, v, k) into (func)(*v, **k)."""
7
+
8
+ # Local imports
9
+ from .. import pytree
10
+ from ..pgen2 import token
11
+ from .. import fixer_base
12
+ from ..fixer_util import Call, Comma, parenthesize
13
+
14
+ class FixApply(fixer_base.BaseFix):
15
+ BM_compatible = True
16
+
17
+ PATTERN = """
18
+ power< 'apply'
19
+ trailer<
20
+ '('
21
+ arglist<
22
+ (not argument<NAME '=' any>) func=any ','
23
+ (not argument<NAME '=' any>) args=any [','
24
+ (not argument<NAME '=' any>) kwds=any] [',']
25
+ >
26
+ ')'
27
+ >
28
+ >
29
+ """
30
+
31
+ def transform(self, node, results):
32
+ syms = self.syms
33
+ assert results
34
+ func = results["func"]
35
+ args = results["args"]
36
+ kwds = results.get("kwds")
37
+ prefix = node.prefix
38
+ func = func.clone()
39
+ if (func.type not in (token.NAME, syms.atom) and
40
+ (func.type != syms.power or
41
+ func.children[-2].type == token.DOUBLESTAR)):
42
+ # Need to parenthesize
43
+ func = parenthesize(func)
44
+ func.prefix = ""
45
+ args = args.clone()
46
+ args.prefix = ""
47
+ if kwds is not None:
48
+ kwds = kwds.clone()
49
+ kwds.prefix = ""
50
+ l_newargs = [pytree.Leaf(token.STAR, u"*"), args]
51
+ if kwds is not None:
52
+ l_newargs.extend([Comma(),
53
+ pytree.Leaf(token.DOUBLESTAR, u"**"),
54
+ kwds])
55
+ l_newargs[-2].prefix = u" " # that's the ** token
56
+ # XXX Sometimes we could be cleverer, e.g. apply(f, (x, y) + t)
57
+ # can be translated into f(x, y, *t) instead of f(*(x, y) + t)
58
+ #new = pytree.Node(syms.power, (func, ArgList(l_newargs)))
59
+ return Call(func, l_newargs, prefix=prefix)
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_basestring.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Fixer for basestring -> str."""
2
+ # Author: Christian Heimes
3
+
4
+ # Local imports
5
+ from .. import fixer_base
6
+ from ..fixer_util import Name
7
+
8
+ class FixBasestring(fixer_base.BaseFix):
9
+ BM_compatible = True
10
+
11
+ PATTERN = "'basestring'"
12
+
13
+ def transform(self, node, results):
14
+ return Name(u"str", prefix=node.prefix)
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_buffer.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2007 Google, Inc. All Rights Reserved.
2
+ # Licensed to PSF under a Contributor Agreement.
3
+
4
+ """Fixer that changes buffer(...) into memoryview(...)."""
5
+
6
+ # Local imports
7
+ from .. import fixer_base
8
+ from ..fixer_util import Name
9
+
10
+
11
+ class FixBuffer(fixer_base.BaseFix):
12
+ BM_compatible = True
13
+
14
+ explicit = True # The user must ask for this fixer
15
+
16
+ PATTERN = """
17
+ power< name='buffer' trailer< '(' [any] ')' > any* >
18
+ """
19
+
20
+ def transform(self, node, results):
21
+ name = results["name"]
22
+ name.replace(Name(u"memoryview", prefix=name.prefix))
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_callable.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2007 Google, Inc. All Rights Reserved.
2
+ # Licensed to PSF under a Contributor Agreement.
3
+
4
+ """Fixer for callable().
5
+
6
+ This converts callable(obj) into isinstance(obj, collections.Callable), adding a
7
+ collections import if needed."""
8
+
9
+ # Local imports
10
+ from lib2to3 import fixer_base
11
+ from lib2to3.fixer_util import Call, Name, String, Attr, touch_import
12
+
13
+ class FixCallable(fixer_base.BaseFix):
14
+ BM_compatible = True
15
+
16
+ order = "pre"
17
+
18
+ # Ignore callable(*args) or use of keywords.
19
+ # Either could be a hint that the builtin callable() is not being used.
20
+ PATTERN = """
21
+ power< 'callable'
22
+ trailer< lpar='('
23
+ ( not(arglist | argument<any '=' any>) func=any
24
+ | func=arglist<(not argument<any '=' any>) any ','> )
25
+ rpar=')' >
26
+ after=any*
27
+ >
28
+ """
29
+
30
+ def transform(self, node, results):
31
+ func = results['func']
32
+
33
+ touch_import(None, u'collections', node=node)
34
+
35
+ args = [func.clone(), String(u', ')]
36
+ args.extend(Attr(Name(u'collections'), Name(u'Callable')))
37
+ return Call(Name(u'isinstance'), args, prefix=node.prefix)
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_dict.py ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2007 Google, Inc. All Rights Reserved.
2
+ # Licensed to PSF under a Contributor Agreement.
3
+
4
+ """Fixer for dict methods.
5
+
6
+ d.keys() -> list(d.keys())
7
+ d.items() -> list(d.items())
8
+ d.values() -> list(d.values())
9
+
10
+ d.iterkeys() -> iter(d.keys())
11
+ d.iteritems() -> iter(d.items())
12
+ d.itervalues() -> iter(d.values())
13
+
14
+ d.viewkeys() -> d.keys()
15
+ d.viewitems() -> d.items()
16
+ d.viewvalues() -> d.values()
17
+
18
+ Except in certain very specific contexts: the iter() can be dropped
19
+ when the context is list(), sorted(), iter() or for...in; the list()
20
+ can be dropped when the context is list() or sorted() (but not iter()
21
+ or for...in!). Special contexts that apply to both: list(), sorted(), tuple()
22
+ set(), any(), all(), sum().
23
+
24
+ Note: iter(d.keys()) could be written as iter(d) but since the
25
+ original d.iterkeys() was also redundant we don't fix this. And there
26
+ are (rare) contexts where it makes a difference (e.g. when passing it
27
+ as an argument to a function that introspects the argument).
28
+ """
29
+
30
+ # Local imports
31
+ from .. import pytree
32
+ from .. import patcomp
33
+ from ..pgen2 import token
34
+ from .. import fixer_base
35
+ from ..fixer_util import Name, Call, LParen, RParen, ArgList, Dot
36
+ from .. import fixer_util
37
+
38
+
39
+ iter_exempt = fixer_util.consuming_calls | set(["iter"])
40
+
41
+
42
+ class FixDict(fixer_base.BaseFix):
43
+ BM_compatible = True
44
+
45
+ PATTERN = """
46
+ power< head=any+
47
+ trailer< '.' method=('keys'|'items'|'values'|
48
+ 'iterkeys'|'iteritems'|'itervalues'|
49
+ 'viewkeys'|'viewitems'|'viewvalues') >
50
+ parens=trailer< '(' ')' >
51
+ tail=any*
52
+ >
53
+ """
54
+
55
+ def transform(self, node, results):
56
+ head = results["head"]
57
+ method = results["method"][0] # Extract node for method name
58
+ tail = results["tail"]
59
+ syms = self.syms
60
+ method_name = method.value
61
+ isiter = method_name.startswith(u"iter")
62
+ isview = method_name.startswith(u"view")
63
+ if isiter or isview:
64
+ method_name = method_name[4:]
65
+ assert method_name in (u"keys", u"items", u"values"), repr(method)
66
+ head = [n.clone() for n in head]
67
+ tail = [n.clone() for n in tail]
68
+ special = not tail and self.in_special_context(node, isiter)
69
+ args = head + [pytree.Node(syms.trailer,
70
+ [Dot(),
71
+ Name(method_name,
72
+ prefix=method.prefix)]),
73
+ results["parens"].clone()]
74
+ new = pytree.Node(syms.power, args)
75
+ if not (special or isview):
76
+ new.prefix = u""
77
+ new = Call(Name(u"iter" if isiter else u"list"), [new])
78
+ if tail:
79
+ new = pytree.Node(syms.power, [new] + tail)
80
+ new.prefix = node.prefix
81
+ return new
82
+
83
+ P1 = "power< func=NAME trailer< '(' node=any ')' > any* >"
84
+ p1 = patcomp.compile_pattern(P1)
85
+
86
+ P2 = """for_stmt< 'for' any 'in' node=any ':' any* >
87
+ | comp_for< 'for' any 'in' node=any any* >
88
+ """
89
+ p2 = patcomp.compile_pattern(P2)
90
+
91
+ def in_special_context(self, node, isiter):
92
+ if node.parent is None:
93
+ return False
94
+ results = {}
95
+ if (node.parent.parent is not None and
96
+ self.p1.match(node.parent.parent, results) and
97
+ results["node"] is node):
98
+ if isiter:
99
+ # iter(d.iterkeys()) -> iter(d.keys()), etc.
100
+ return results["func"].value in iter_exempt
101
+ else:
102
+ # list(d.keys()) -> list(d.keys()), etc.
103
+ return results["func"].value in fixer_util.consuming_calls
104
+ if not isiter:
105
+ return False
106
+ # for ... in d.iterkeys() -> for ... in d.keys(), etc.
107
+ return self.p2.match(node.parent, results) and results["node"] is node
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_except.py ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Fixer for except statements with named exceptions.
2
+
3
+ The following cases will be converted:
4
+
5
+ - "except E, T:" where T is a name:
6
+
7
+ except E as T:
8
+
9
+ - "except E, T:" where T is not a name, tuple or list:
10
+
11
+ except E as t:
12
+ T = t
13
+
14
+ This is done because the target of an "except" clause must be a
15
+ name.
16
+
17
+ - "except E, T:" where T is a tuple or list literal:
18
+
19
+ except E as t:
20
+ T = t.args
21
+ """
22
+ # Author: Collin Winter
23
+
24
+ # Local imports
25
+ from .. import pytree
26
+ from ..pgen2 import token
27
+ from .. import fixer_base
28
+ from ..fixer_util import Assign, Attr, Name, is_tuple, is_list, syms
29
+
30
+ def find_excepts(nodes):
31
+ for i, n in enumerate(nodes):
32
+ if n.type == syms.except_clause:
33
+ if n.children[0].value == u'except':
34
+ yield (n, nodes[i+2])
35
+
36
+ class FixExcept(fixer_base.BaseFix):
37
+ BM_compatible = True
38
+
39
+ PATTERN = """
40
+ try_stmt< 'try' ':' (simple_stmt | suite)
41
+ cleanup=(except_clause ':' (simple_stmt | suite))+
42
+ tail=(['except' ':' (simple_stmt | suite)]
43
+ ['else' ':' (simple_stmt | suite)]
44
+ ['finally' ':' (simple_stmt | suite)]) >
45
+ """
46
+
47
+ def transform(self, node, results):
48
+ syms = self.syms
49
+
50
+ tail = [n.clone() for n in results["tail"]]
51
+
52
+ try_cleanup = [ch.clone() for ch in results["cleanup"]]
53
+ for except_clause, e_suite in find_excepts(try_cleanup):
54
+ if len(except_clause.children) == 4:
55
+ (E, comma, N) = except_clause.children[1:4]
56
+ comma.replace(Name(u"as", prefix=u" "))
57
+
58
+ if N.type != token.NAME:
59
+ # Generate a new N for the except clause
60
+ new_N = Name(self.new_name(), prefix=u" ")
61
+ target = N.clone()
62
+ target.prefix = u""
63
+ N.replace(new_N)
64
+ new_N = new_N.clone()
65
+
66
+ # Insert "old_N = new_N" as the first statement in
67
+ # the except body. This loop skips leading whitespace
68
+ # and indents
69
+ #TODO(cwinter) suite-cleanup
70
+ suite_stmts = e_suite.children
71
+ for i, stmt in enumerate(suite_stmts):
72
+ if isinstance(stmt, pytree.Node):
73
+ break
74
+
75
+ # The assignment is different if old_N is a tuple or list
76
+ # In that case, the assignment is old_N = new_N.args
77
+ if is_tuple(N) or is_list(N):
78
+ assign = Assign(target, Attr(new_N, Name(u'args')))
79
+ else:
80
+ assign = Assign(target, new_N)
81
+
82
+ #TODO(cwinter) stopgap until children becomes a smart list
83
+ for child in reversed(suite_stmts[:i]):
84
+ e_suite.insert_child(0, child)
85
+ e_suite.insert_child(i, assign)
86
+ elif N.prefix == u"":
87
+ # No space after a comma is legal; no space after "as",
88
+ # not so much.
89
+ N.prefix = u" "
90
+
91
+ #TODO(cwinter) fix this when children becomes a smart list
92
+ children = [c.clone() for c in node.children[:3]] + try_cleanup + tail
93
+ return pytree.Node(node.type, children)
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_exec.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2006 Google, Inc. All Rights Reserved.
2
+ # Licensed to PSF under a Contributor Agreement.
3
+
4
+ """Fixer for exec.
5
+
6
+ This converts usages of the exec statement into calls to a built-in
7
+ exec() function.
8
+
9
+ exec code in ns1, ns2 -> exec(code, ns1, ns2)
10
+ """
11
+
12
+ # Local imports
13
+ from .. import pytree
14
+ from .. import fixer_base
15
+ from ..fixer_util import Comma, Name, Call
16
+
17
+
18
+ class FixExec(fixer_base.BaseFix):
19
+ BM_compatible = True
20
+
21
+ PATTERN = """
22
+ exec_stmt< 'exec' a=any 'in' b=any [',' c=any] >
23
+ |
24
+ exec_stmt< 'exec' (not atom<'(' [any] ')'>) a=any >
25
+ """
26
+
27
+ def transform(self, node, results):
28
+ assert results
29
+ syms = self.syms
30
+ a = results["a"]
31
+ b = results.get("b")
32
+ c = results.get("c")
33
+ args = [a.clone()]
34
+ args[0].prefix = ""
35
+ if b is not None:
36
+ args.extend([Comma(), b.clone()])
37
+ if c is not None:
38
+ args.extend([Comma(), c.clone()])
39
+
40
+ return Call(Name(u"exec"), args, prefix=node.prefix)
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_execfile.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2006 Google, Inc. All Rights Reserved.
2
+ # Licensed to PSF under a Contributor Agreement.
3
+
4
+ """Fixer for execfile.
5
+
6
+ This converts usages of the execfile function into calls to the built-in
7
+ exec() function.
8
+ """
9
+
10
+ from .. import fixer_base
11
+ from ..fixer_util import (Comma, Name, Call, LParen, RParen, Dot, Node,
12
+ ArgList, String, syms)
13
+
14
+
15
+ class FixExecfile(fixer_base.BaseFix):
16
+ BM_compatible = True
17
+
18
+ PATTERN = """
19
+ power< 'execfile' trailer< '(' arglist< filename=any [',' globals=any [',' locals=any ] ] > ')' > >
20
+ |
21
+ power< 'execfile' trailer< '(' filename=any ')' > >
22
+ """
23
+
24
+ def transform(self, node, results):
25
+ assert results
26
+ filename = results["filename"]
27
+ globals = results.get("globals")
28
+ locals = results.get("locals")
29
+
30
+ # Copy over the prefix from the right parentheses end of the execfile
31
+ # call.
32
+ execfile_paren = node.children[-1].children[-1].clone()
33
+ # Construct open().read().
34
+ open_args = ArgList([filename.clone()], rparen=execfile_paren)
35
+ open_call = Node(syms.power, [Name(u"open"), open_args])
36
+ read = [Node(syms.trailer, [Dot(), Name(u'read')]),
37
+ Node(syms.trailer, [LParen(), RParen()])]
38
+ open_expr = [open_call] + read
39
+ # Wrap the open call in a compile call. This is so the filename will be
40
+ # preserved in the execed code.
41
+ filename_arg = filename.clone()
42
+ filename_arg.prefix = u" "
43
+ exec_str = String(u"'exec'", u" ")
44
+ compile_args = open_expr + [Comma(), filename_arg, Comma(), exec_str]
45
+ compile_call = Call(Name(u"compile"), compile_args, u"")
46
+ # Finally, replace the execfile call with an exec call.
47
+ args = [compile_call]
48
+ if globals is not None:
49
+ args.extend([Comma(), globals.clone()])
50
+ if locals is not None:
51
+ args.extend([Comma(), locals.clone()])
52
+ return Call(Name(u"exec"), args, prefix=node.prefix)
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_exitfunc.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Convert use of sys.exitfunc to use the atexit module.
3
+ """
4
+
5
+ # Author: Benjamin Peterson
6
+
7
+ from lib2to3 import pytree, fixer_base
8
+ from lib2to3.fixer_util import Name, Attr, Call, Comma, Newline, syms
9
+
10
+
11
+ class FixExitfunc(fixer_base.BaseFix):
12
+ keep_line_order = True
13
+ BM_compatible = True
14
+
15
+ PATTERN = """
16
+ (
17
+ sys_import=import_name<'import'
18
+ ('sys'
19
+ |
20
+ dotted_as_names< (any ',')* 'sys' (',' any)* >
21
+ )
22
+ >
23
+ |
24
+ expr_stmt<
25
+ power< 'sys' trailer< '.' 'exitfunc' > >
26
+ '=' func=any >
27
+ )
28
+ """
29
+
30
+ def __init__(self, *args):
31
+ super(FixExitfunc, self).__init__(*args)
32
+
33
+ def start_tree(self, tree, filename):
34
+ super(FixExitfunc, self).start_tree(tree, filename)
35
+ self.sys_import = None
36
+
37
+ def transform(self, node, results):
38
+ # First, find a the sys import. We'll just hope it's global scope.
39
+ if "sys_import" in results:
40
+ if self.sys_import is None:
41
+ self.sys_import = results["sys_import"]
42
+ return
43
+
44
+ func = results["func"].clone()
45
+ func.prefix = u""
46
+ register = pytree.Node(syms.power,
47
+ Attr(Name(u"atexit"), Name(u"register"))
48
+ )
49
+ call = Call(register, [func], node.prefix)
50
+ node.replace(call)
51
+
52
+ if self.sys_import is None:
53
+ # That's interesting.
54
+ self.warning(node, "Can't find sys import; Please add an atexit "
55
+ "import at the top of your file.")
56
+ return
57
+
58
+ # Now add an atexit import after the sys import.
59
+ names = self.sys_import.children[1]
60
+ if names.type == syms.dotted_as_names:
61
+ names.append_child(Comma())
62
+ names.append_child(Name(u"atexit", u" "))
63
+ else:
64
+ containing_stmt = self.sys_import.parent
65
+ position = containing_stmt.children.index(self.sys_import)
66
+ stmt_container = containing_stmt.parent
67
+ new_import = pytree.Node(syms.import_name,
68
+ [Name(u"import"), Name(u"atexit", u" ")]
69
+ )
70
+ new = pytree.Node(syms.simple_stmt, [new_import])
71
+ containing_stmt.insert_child(position + 1, Newline())
72
+ containing_stmt.insert_child(position + 2, new)
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_filter.py ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2007 Google, Inc. All Rights Reserved.
2
+ # Licensed to PSF under a Contributor Agreement.
3
+
4
+ """Fixer that changes filter(F, X) into list(filter(F, X)).
5
+
6
+ We avoid the transformation if the filter() call is directly contained
7
+ in iter(<>), list(<>), tuple(<>), sorted(<>), ...join(<>), or
8
+ for V in <>:.
9
+
10
+ NOTE: This is still not correct if the original code was depending on
11
+ filter(F, X) to return a string if X is a string and a tuple if X is a
12
+ tuple. That would require type inference, which we don't do. Let
13
+ Python 2.6 figure it out.
14
+ """
15
+
16
+ # Local imports
17
+ from ..pgen2 import token
18
+ from .. import fixer_base
19
+ from ..fixer_util import Name, Call, ListComp, in_special_context
20
+
21
+ class FixFilter(fixer_base.ConditionalFix):
22
+ BM_compatible = True
23
+
24
+ PATTERN = """
25
+ filter_lambda=power<
26
+ 'filter'
27
+ trailer<
28
+ '('
29
+ arglist<
30
+ lambdef< 'lambda'
31
+ (fp=NAME | vfpdef< '(' fp=NAME ')'> ) ':' xp=any
32
+ >
33
+ ','
34
+ it=any
35
+ >
36
+ ')'
37
+ >
38
+ >
39
+ |
40
+ power<
41
+ 'filter'
42
+ trailer< '(' arglist< none='None' ',' seq=any > ')' >
43
+ >
44
+ |
45
+ power<
46
+ 'filter'
47
+ args=trailer< '(' [any] ')' >
48
+ >
49
+ """
50
+
51
+ skip_on = "future_builtins.filter"
52
+
53
+ def transform(self, node, results):
54
+ if self.should_skip(node):
55
+ return
56
+
57
+ if "filter_lambda" in results:
58
+ new = ListComp(results.get("fp").clone(),
59
+ results.get("fp").clone(),
60
+ results.get("it").clone(),
61
+ results.get("xp").clone())
62
+
63
+ elif "none" in results:
64
+ new = ListComp(Name(u"_f"),
65
+ Name(u"_f"),
66
+ results["seq"].clone(),
67
+ Name(u"_f"))
68
+
69
+ else:
70
+ if in_special_context(node):
71
+ return None
72
+ new = node.clone()
73
+ new.prefix = u""
74
+ new = Call(Name(u"list"), [new])
75
+ new.prefix = node.prefix
76
+ return new
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_funcattrs.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Fix function attribute names (f.func_x -> f.__x__)."""
2
+ # Author: Collin Winter
3
+
4
+ # Local imports
5
+ from .. import fixer_base
6
+ from ..fixer_util import Name
7
+
8
+
9
+ class FixFuncattrs(fixer_base.BaseFix):
10
+ BM_compatible = True
11
+
12
+ PATTERN = """
13
+ power< any+ trailer< '.' attr=('func_closure' | 'func_doc' | 'func_globals'
14
+ | 'func_name' | 'func_defaults' | 'func_code'
15
+ | 'func_dict') > any* >
16
+ """
17
+
18
+ def transform(self, node, results):
19
+ attr = results["attr"][0]
20
+ attr.replace(Name((u"__%s__" % attr.value[5:]),
21
+ prefix=attr.prefix))
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_future.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Remove __future__ imports
2
+
3
+ from __future__ import foo is replaced with an empty line.
4
+ """
5
+ # Author: Christian Heimes
6
+
7
+ # Local imports
8
+ from .. import fixer_base
9
+ from ..fixer_util import BlankLine
10
+
11
+ class FixFuture(fixer_base.BaseFix):
12
+ BM_compatible = True
13
+
14
+ PATTERN = """import_from< 'from' module_name="__future__" 'import' any >"""
15
+
16
+ # This should be run last -- some things check for the import
17
+ run_order = 10
18
+
19
+ def transform(self, node, results):
20
+ new = BlankLine()
21
+ new.prefix = node.prefix
22
+ return new
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_getcwdu.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Fixer that changes os.getcwdu() to os.getcwd().
3
+ """
4
+ # Author: Victor Stinner
5
+
6
+ # Local imports
7
+ from .. import fixer_base
8
+ from ..fixer_util import Name
9
+
10
+ class FixGetcwdu(fixer_base.BaseFix):
11
+ BM_compatible = True
12
+
13
+ PATTERN = """
14
+ power< 'os' trailer< dot='.' name='getcwdu' > any* >
15
+ """
16
+
17
+ def transform(self, node, results):
18
+ name = results["name"]
19
+ name.replace(Name(u"getcwd", prefix=name.prefix))
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_has_key.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2006 Google, Inc. All Rights Reserved.
2
+ # Licensed to PSF under a Contributor Agreement.
3
+
4
+ """Fixer for has_key().
5
+
6
+ Calls to .has_key() methods are expressed in terms of the 'in'
7
+ operator:
8
+
9
+ d.has_key(k) -> k in d
10
+
11
+ CAVEATS:
12
+ 1) While the primary target of this fixer is dict.has_key(), the
13
+ fixer will change any has_key() method call, regardless of its
14
+ class.
15
+
16
+ 2) Cases like this will not be converted:
17
+
18
+ m = d.has_key
19
+ if m(k):
20
+ ...
21
+
22
+ Only *calls* to has_key() are converted. While it is possible to
23
+ convert the above to something like
24
+
25
+ m = d.__contains__
26
+ if m(k):
27
+ ...
28
+
29
+ this is currently not done.
30
+ """
31
+
32
+ # Local imports
33
+ from .. import pytree
34
+ from ..pgen2 import token
35
+ from .. import fixer_base
36
+ from ..fixer_util import Name, parenthesize
37
+
38
+
39
+ class FixHasKey(fixer_base.BaseFix):
40
+ BM_compatible = True
41
+
42
+ PATTERN = """
43
+ anchor=power<
44
+ before=any+
45
+ trailer< '.' 'has_key' >
46
+ trailer<
47
+ '('
48
+ ( not(arglist | argument<any '=' any>) arg=any
49
+ | arglist<(not argument<any '=' any>) arg=any ','>
50
+ )
51
+ ')'
52
+ >
53
+ after=any*
54
+ >
55
+ |
56
+ negation=not_test<
57
+ 'not'
58
+ anchor=power<
59
+ before=any+
60
+ trailer< '.' 'has_key' >
61
+ trailer<
62
+ '('
63
+ ( not(arglist | argument<any '=' any>) arg=any
64
+ | arglist<(not argument<any '=' any>) arg=any ','>
65
+ )
66
+ ')'
67
+ >
68
+ >
69
+ >
70
+ """
71
+
72
+ def transform(self, node, results):
73
+ assert results
74
+ syms = self.syms
75
+ if (node.parent.type == syms.not_test and
76
+ self.pattern.match(node.parent)):
77
+ # Don't transform a node matching the first alternative of the
78
+ # pattern when its parent matches the second alternative
79
+ return None
80
+ negation = results.get("negation")
81
+ anchor = results["anchor"]
82
+ prefix = node.prefix
83
+ before = [n.clone() for n in results["before"]]
84
+ arg = results["arg"].clone()
85
+ after = results.get("after")
86
+ if after:
87
+ after = [n.clone() for n in after]
88
+ if arg.type in (syms.comparison, syms.not_test, syms.and_test,
89
+ syms.or_test, syms.test, syms.lambdef, syms.argument):
90
+ arg = parenthesize(arg)
91
+ if len(before) == 1:
92
+ before = before[0]
93
+ else:
94
+ before = pytree.Node(syms.power, before)
95
+ before.prefix = u" "
96
+ n_op = Name(u"in", prefix=u" ")
97
+ if negation:
98
+ n_not = Name(u"not", prefix=u" ")
99
+ n_op = pytree.Node(syms.comp_op, (n_not, n_op))
100
+ new = pytree.Node(syms.comparison, (arg, n_op, before))
101
+ if after:
102
+ new = parenthesize(new)
103
+ new = pytree.Node(syms.power, (new,) + tuple(after))
104
+ if node.parent.type in (syms.comparison, syms.expr, syms.xor_expr,
105
+ syms.and_expr, syms.shift_expr,
106
+ syms.arith_expr, syms.term,
107
+ syms.factor, syms.power):
108
+ new = parenthesize(new)
109
+ new.prefix = prefix
110
+ return new
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_idioms.py ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Adjust some old Python 2 idioms to their modern counterparts.
2
+
3
+ * Change some type comparisons to isinstance() calls:
4
+ type(x) == T -> isinstance(x, T)
5
+ type(x) is T -> isinstance(x, T)
6
+ type(x) != T -> not isinstance(x, T)
7
+ type(x) is not T -> not isinstance(x, T)
8
+
9
+ * Change "while 1:" into "while True:".
10
+
11
+ * Change both
12
+
13
+ v = list(EXPR)
14
+ v.sort()
15
+ foo(v)
16
+
17
+ and the more general
18
+
19
+ v = EXPR
20
+ v.sort()
21
+ foo(v)
22
+
23
+ into
24
+
25
+ v = sorted(EXPR)
26
+ foo(v)
27
+ """
28
+ # Author: Jacques Frechet, Collin Winter
29
+
30
+ # Local imports
31
+ from .. import fixer_base
32
+ from ..fixer_util import Call, Comma, Name, Node, BlankLine, syms
33
+
34
+ CMP = "(n='!=' | '==' | 'is' | n=comp_op< 'is' 'not' >)"
35
+ TYPE = "power< 'type' trailer< '(' x=any ')' > >"
36
+
37
+ class FixIdioms(fixer_base.BaseFix):
38
+ explicit = True # The user must ask for this fixer
39
+
40
+ PATTERN = r"""
41
+ isinstance=comparison< %s %s T=any >
42
+ |
43
+ isinstance=comparison< T=any %s %s >
44
+ |
45
+ while_stmt< 'while' while='1' ':' any+ >
46
+ |
47
+ sorted=any<
48
+ any*
49
+ simple_stmt<
50
+ expr_stmt< id1=any '='
51
+ power< list='list' trailer< '(' (not arglist<any+>) any ')' > >
52
+ >
53
+ '\n'
54
+ >
55
+ sort=
56
+ simple_stmt<
57
+ power< id2=any
58
+ trailer< '.' 'sort' > trailer< '(' ')' >
59
+ >
60
+ '\n'
61
+ >
62
+ next=any*
63
+ >
64
+ |
65
+ sorted=any<
66
+ any*
67
+ simple_stmt< expr_stmt< id1=any '=' expr=any > '\n' >
68
+ sort=
69
+ simple_stmt<
70
+ power< id2=any
71
+ trailer< '.' 'sort' > trailer< '(' ')' >
72
+ >
73
+ '\n'
74
+ >
75
+ next=any*
76
+ >
77
+ """ % (TYPE, CMP, CMP, TYPE)
78
+
79
+ def match(self, node):
80
+ r = super(FixIdioms, self).match(node)
81
+ # If we've matched one of the sort/sorted subpatterns above, we
82
+ # want to reject matches where the initial assignment and the
83
+ # subsequent .sort() call involve different identifiers.
84
+ if r and "sorted" in r:
85
+ if r["id1"] == r["id2"]:
86
+ return r
87
+ return None
88
+ return r
89
+
90
+ def transform(self, node, results):
91
+ if "isinstance" in results:
92
+ return self.transform_isinstance(node, results)
93
+ elif "while" in results:
94
+ return self.transform_while(node, results)
95
+ elif "sorted" in results:
96
+ return self.transform_sort(node, results)
97
+ else:
98
+ raise RuntimeError("Invalid match")
99
+
100
+ def transform_isinstance(self, node, results):
101
+ x = results["x"].clone() # The thing inside of type()
102
+ T = results["T"].clone() # The type being compared against
103
+ x.prefix = u""
104
+ T.prefix = u" "
105
+ test = Call(Name(u"isinstance"), [x, Comma(), T])
106
+ if "n" in results:
107
+ test.prefix = u" "
108
+ test = Node(syms.not_test, [Name(u"not"), test])
109
+ test.prefix = node.prefix
110
+ return test
111
+
112
+ def transform_while(self, node, results):
113
+ one = results["while"]
114
+ one.replace(Name(u"True", prefix=one.prefix))
115
+
116
+ def transform_sort(self, node, results):
117
+ sort_stmt = results["sort"]
118
+ next_stmt = results["next"]
119
+ list_call = results.get("list")
120
+ simple_expr = results.get("expr")
121
+
122
+ if list_call:
123
+ list_call.replace(Name(u"sorted", prefix=list_call.prefix))
124
+ elif simple_expr:
125
+ new = simple_expr.clone()
126
+ new.prefix = u""
127
+ simple_expr.replace(Call(Name(u"sorted"), [new],
128
+ prefix=simple_expr.prefix))
129
+ else:
130
+ raise RuntimeError("should not have reached here")
131
+ sort_stmt.remove()
132
+
133
+ btwn = sort_stmt.prefix
134
+ # Keep any prefix lines between the sort_stmt and the list_call and
135
+ # shove them right after the sorted() call.
136
+ if u"\n" in btwn:
137
+ if next_stmt:
138
+ # The new prefix should be everything from the sort_stmt's
139
+ # prefix up to the last newline, then the old prefix after a new
140
+ # line.
141
+ prefix_lines = (btwn.rpartition(u"\n")[0], next_stmt[0].prefix)
142
+ next_stmt[0].prefix = u"\n".join(prefix_lines)
143
+ else:
144
+ assert list_call.parent
145
+ assert list_call.next_sibling is None
146
+ # Put a blank line after list_call and set its prefix.
147
+ end_line = BlankLine()
148
+ list_call.parent.append_child(end_line)
149
+ assert list_call.next_sibling is end_line
150
+ # The new prefix should be everything up to the first new line
151
+ # of sort_stmt's prefix.
152
+ end_line.prefix = btwn.rpartition(u"\n")[0]
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_import.py ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Fixer for import statements.
2
+ If spam is being imported from the local directory, this import:
3
+ from spam import eggs
4
+ Becomes:
5
+ from .spam import eggs
6
+
7
+ And this import:
8
+ import spam
9
+ Becomes:
10
+ from . import spam
11
+ """
12
+
13
+ # Local imports
14
+ from .. import fixer_base
15
+ from os.path import dirname, join, exists, sep
16
+ from ..fixer_util import FromImport, syms, token
17
+
18
+
19
+ def traverse_imports(names):
20
+ """
21
+ Walks over all the names imported in a dotted_as_names node.
22
+ """
23
+ pending = [names]
24
+ while pending:
25
+ node = pending.pop()
26
+ if node.type == token.NAME:
27
+ yield node.value
28
+ elif node.type == syms.dotted_name:
29
+ yield "".join([ch.value for ch in node.children])
30
+ elif node.type == syms.dotted_as_name:
31
+ pending.append(node.children[0])
32
+ elif node.type == syms.dotted_as_names:
33
+ pending.extend(node.children[::-2])
34
+ else:
35
+ raise AssertionError("unknown node type")
36
+
37
+
38
+ class FixImport(fixer_base.BaseFix):
39
+ BM_compatible = True
40
+
41
+ PATTERN = """
42
+ import_from< 'from' imp=any 'import' ['('] any [')'] >
43
+ |
44
+ import_name< 'import' imp=any >
45
+ """
46
+
47
+ def start_tree(self, tree, name):
48
+ super(FixImport, self).start_tree(tree, name)
49
+ self.skip = "absolute_import" in tree.future_features
50
+
51
+ def transform(self, node, results):
52
+ if self.skip:
53
+ return
54
+ imp = results['imp']
55
+
56
+ if node.type == syms.import_from:
57
+ # Some imps are top-level (eg: 'import ham')
58
+ # some are first level (eg: 'import ham.eggs')
59
+ # some are third level (eg: 'import ham.eggs as spam')
60
+ # Hence, the loop
61
+ while not hasattr(imp, 'value'):
62
+ imp = imp.children[0]
63
+ if self.probably_a_local_import(imp.value):
64
+ imp.value = u"." + imp.value
65
+ imp.changed()
66
+ else:
67
+ have_local = False
68
+ have_absolute = False
69
+ for mod_name in traverse_imports(imp):
70
+ if self.probably_a_local_import(mod_name):
71
+ have_local = True
72
+ else:
73
+ have_absolute = True
74
+ if have_absolute:
75
+ if have_local:
76
+ # We won't handle both sibling and absolute imports in the
77
+ # same statement at the moment.
78
+ self.warning(node, "absolute and local imports together")
79
+ return
80
+
81
+ new = FromImport(u".", [imp])
82
+ new.prefix = node.prefix
83
+ return new
84
+
85
+ def probably_a_local_import(self, imp_name):
86
+ if imp_name.startswith(u"."):
87
+ # Relative imports are certainly not local imports.
88
+ return False
89
+ imp_name = imp_name.split(u".", 1)[0]
90
+ base_path = dirname(self.filename)
91
+ base_path = join(base_path, imp_name)
92
+ # If there is no __init__.py next to the file its not in a package
93
+ # so can't be a relative import.
94
+ if not exists(join(dirname(base_path), "__init__.py")):
95
+ return False
96
+ for ext in [".py", sep, ".pyc", ".so", ".sl", ".pyd"]:
97
+ if exists(base_path + ext):
98
+ return True
99
+ return False
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_imports.py ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Fix incompatible imports and module references."""
2
+ # Authors: Collin Winter, Nick Edds
3
+
4
+ # Local imports
5
+ from .. import fixer_base
6
+ from ..fixer_util import Name, attr_chain
7
+
8
+ MAPPING = {'StringIO': 'io',
9
+ 'cStringIO': 'io',
10
+ 'cPickle': 'pickle',
11
+ '__builtin__' : 'builtins',
12
+ 'copy_reg': 'copyreg',
13
+ 'Queue': 'queue',
14
+ 'SocketServer': 'socketserver',
15
+ 'ConfigParser': 'configparser',
16
+ 'repr': 'reprlib',
17
+ 'FileDialog': 'tkinter.filedialog',
18
+ 'tkFileDialog': 'tkinter.filedialog',
19
+ 'SimpleDialog': 'tkinter.simpledialog',
20
+ 'tkSimpleDialog': 'tkinter.simpledialog',
21
+ 'tkColorChooser': 'tkinter.colorchooser',
22
+ 'tkCommonDialog': 'tkinter.commondialog',
23
+ 'Dialog': 'tkinter.dialog',
24
+ 'Tkdnd': 'tkinter.dnd',
25
+ 'tkFont': 'tkinter.font',
26
+ 'tkMessageBox': 'tkinter.messagebox',
27
+ 'ScrolledText': 'tkinter.scrolledtext',
28
+ 'Tkconstants': 'tkinter.constants',
29
+ 'Tix': 'tkinter.tix',
30
+ 'ttk': 'tkinter.ttk',
31
+ 'Tkinter': 'tkinter',
32
+ 'markupbase': '_markupbase',
33
+ '_winreg': 'winreg',
34
+ 'thread': '_thread',
35
+ 'dummy_thread': '_dummy_thread',
36
+ # anydbm and whichdb are handled by fix_imports2
37
+ 'dbhash': 'dbm.bsd',
38
+ 'dumbdbm': 'dbm.dumb',
39
+ 'dbm': 'dbm.ndbm',
40
+ 'gdbm': 'dbm.gnu',
41
+ 'xmlrpclib': 'xmlrpc.client',
42
+ 'DocXMLRPCServer': 'xmlrpc.server',
43
+ 'SimpleXMLRPCServer': 'xmlrpc.server',
44
+ 'httplib': 'http.client',
45
+ 'htmlentitydefs' : 'html.entities',
46
+ 'HTMLParser' : 'html.parser',
47
+ 'Cookie': 'http.cookies',
48
+ 'cookielib': 'http.cookiejar',
49
+ 'BaseHTTPServer': 'http.server',
50
+ 'SimpleHTTPServer': 'http.server',
51
+ 'CGIHTTPServer': 'http.server',
52
+ #'test.test_support': 'test.support',
53
+ 'commands': 'subprocess',
54
+ 'UserString' : 'collections',
55
+ 'UserList' : 'collections',
56
+ 'urlparse' : 'urllib.parse',
57
+ 'robotparser' : 'urllib.robotparser',
58
+ }
59
+
60
+
61
+ def alternates(members):
62
+ return "(" + "|".join(map(repr, members)) + ")"
63
+
64
+
65
+ def build_pattern(mapping=MAPPING):
66
+ mod_list = ' | '.join(["module_name='%s'" % key for key in mapping])
67
+ bare_names = alternates(mapping.keys())
68
+
69
+ yield """name_import=import_name< 'import' ((%s) |
70
+ multiple_imports=dotted_as_names< any* (%s) any* >) >
71
+ """ % (mod_list, mod_list)
72
+ yield """import_from< 'from' (%s) 'import' ['(']
73
+ ( any | import_as_name< any 'as' any > |
74
+ import_as_names< any* >) [')'] >
75
+ """ % mod_list
76
+ yield """import_name< 'import' (dotted_as_name< (%s) 'as' any > |
77
+ multiple_imports=dotted_as_names<
78
+ any* dotted_as_name< (%s) 'as' any > any* >) >
79
+ """ % (mod_list, mod_list)
80
+
81
+ # Find usages of module members in code e.g. thread.foo(bar)
82
+ yield "power< bare_with_attr=(%s) trailer<'.' any > any* >" % bare_names
83
+
84
+
85
+ class FixImports(fixer_base.BaseFix):
86
+
87
+ BM_compatible = True
88
+ keep_line_order = True
89
+ # This is overridden in fix_imports2.
90
+ mapping = MAPPING
91
+
92
+ # We want to run this fixer late, so fix_import doesn't try to make stdlib
93
+ # renames into relative imports.
94
+ run_order = 6
95
+
96
+ def build_pattern(self):
97
+ return "|".join(build_pattern(self.mapping))
98
+
99
+ def compile_pattern(self):
100
+ # We override this, so MAPPING can be pragmatically altered and the
101
+ # changes will be reflected in PATTERN.
102
+ self.PATTERN = self.build_pattern()
103
+ super(FixImports, self).compile_pattern()
104
+
105
+ # Don't match the node if it's within another match.
106
+ def match(self, node):
107
+ match = super(FixImports, self).match
108
+ results = match(node)
109
+ if results:
110
+ # Module usage could be in the trailer of an attribute lookup, so we
111
+ # might have nested matches when "bare_with_attr" is present.
112
+ if "bare_with_attr" not in results and \
113
+ any(match(obj) for obj in attr_chain(node, "parent")):
114
+ return False
115
+ return results
116
+ return False
117
+
118
+ def start_tree(self, tree, filename):
119
+ super(FixImports, self).start_tree(tree, filename)
120
+ self.replace = {}
121
+
122
+ def transform(self, node, results):
123
+ import_mod = results.get("module_name")
124
+ if import_mod:
125
+ mod_name = import_mod.value
126
+ new_name = unicode(self.mapping[mod_name])
127
+ import_mod.replace(Name(new_name, prefix=import_mod.prefix))
128
+ if "name_import" in results:
129
+ # If it's not a "from x import x, y" or "import x as y" import,
130
+ # marked its usage to be replaced.
131
+ self.replace[mod_name] = new_name
132
+ if "multiple_imports" in results:
133
+ # This is a nasty hack to fix multiple imports on a line (e.g.,
134
+ # "import StringIO, urlparse"). The problem is that I can't
135
+ # figure out an easy way to make a pattern recognize the keys of
136
+ # MAPPING randomly sprinkled in an import statement.
137
+ results = self.match(node)
138
+ if results:
139
+ self.transform(node, results)
140
+ else:
141
+ # Replace usage of the module.
142
+ bare_name = results["bare_with_attr"][0]
143
+ new_name = self.replace.get(bare_name.value)
144
+ if new_name:
145
+ bare_name.replace(Name(new_name, prefix=bare_name.prefix))
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_imports2.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Fix incompatible imports and module references that must be fixed after
2
+ fix_imports."""
3
+ from . import fix_imports
4
+
5
+
6
+ MAPPING = {
7
+ 'whichdb': 'dbm',
8
+ 'anydbm': 'dbm',
9
+ }
10
+
11
+
12
+ class FixImports2(fix_imports.FixImports):
13
+
14
+ run_order = 7
15
+
16
+ mapping = MAPPING
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_input.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Fixer that changes input(...) into eval(input(...))."""
2
+ # Author: Andre Roberge
3
+
4
+ # Local imports
5
+ from .. import fixer_base
6
+ from ..fixer_util import Call, Name
7
+ from .. import patcomp
8
+
9
+
10
+ context = patcomp.compile_pattern("power< 'eval' trailer< '(' any ')' > >")
11
+
12
+
13
+ class FixInput(fixer_base.BaseFix):
14
+ BM_compatible = True
15
+ PATTERN = """
16
+ power< 'input' args=trailer< '(' [any] ')' > >
17
+ """
18
+
19
+ def transform(self, node, results):
20
+ # If we're already wrapped in a eval() call, we're done.
21
+ if context.match(node.parent.parent):
22
+ return
23
+
24
+ new = node.clone()
25
+ new.prefix = u""
26
+ return Call(Name(u"eval"), [new], prefix=node.prefix)
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_intern.py ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2006 Georg Brandl.
2
+ # Licensed to PSF under a Contributor Agreement.
3
+
4
+ """Fixer for intern().
5
+
6
+ intern(s) -> sys.intern(s)"""
7
+
8
+ # Local imports
9
+ from .. import pytree
10
+ from .. import fixer_base
11
+ from ..fixer_util import Name, Attr, touch_import
12
+
13
+
14
+ class FixIntern(fixer_base.BaseFix):
15
+ BM_compatible = True
16
+ order = "pre"
17
+
18
+ PATTERN = """
19
+ power< 'intern'
20
+ trailer< lpar='('
21
+ ( not(arglist | argument<any '=' any>) obj=any
22
+ | obj=arglist<(not argument<any '=' any>) any ','> )
23
+ rpar=')' >
24
+ after=any*
25
+ >
26
+ """
27
+
28
+ def transform(self, node, results):
29
+ syms = self.syms
30
+ obj = results["obj"].clone()
31
+ if obj.type == syms.arglist:
32
+ newarglist = obj.clone()
33
+ else:
34
+ newarglist = pytree.Node(syms.arglist, [obj.clone()])
35
+ after = results["after"]
36
+ if after:
37
+ after = [n.clone() for n in after]
38
+ new = pytree.Node(syms.power,
39
+ Attr(Name(u"sys"), Name(u"intern")) +
40
+ [pytree.Node(syms.trailer,
41
+ [results["lpar"].clone(),
42
+ newarglist,
43
+ results["rpar"].clone()])] + after)
44
+ new.prefix = node.prefix
45
+ touch_import(None, u'sys', node)
46
+ return new
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_isinstance.py ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2008 Armin Ronacher.
2
+ # Licensed to PSF under a Contributor Agreement.
3
+
4
+ """Fixer that cleans up a tuple argument to isinstance after the tokens
5
+ in it were fixed. This is mainly used to remove double occurrences of
6
+ tokens as a leftover of the long -> int / unicode -> str conversion.
7
+
8
+ eg. isinstance(x, (int, long)) -> isinstance(x, (int, int))
9
+ -> isinstance(x, int)
10
+ """
11
+
12
+ from .. import fixer_base
13
+ from ..fixer_util import token
14
+
15
+
16
+ class FixIsinstance(fixer_base.BaseFix):
17
+ BM_compatible = True
18
+ PATTERN = """
19
+ power<
20
+ 'isinstance'
21
+ trailer< '(' arglist< any ',' atom< '('
22
+ args=testlist_gexp< any+ >
23
+ ')' > > ')' >
24
+ >
25
+ """
26
+
27
+ run_order = 6
28
+
29
+ def transform(self, node, results):
30
+ names_inserted = set()
31
+ testlist = results["args"]
32
+ args = testlist.children
33
+ new_args = []
34
+ iterator = enumerate(args)
35
+ for idx, arg in iterator:
36
+ if arg.type == token.NAME and arg.value in names_inserted:
37
+ if idx < len(args) - 1 and args[idx + 1].type == token.COMMA:
38
+ iterator.next()
39
+ continue
40
+ else:
41
+ new_args.append(arg)
42
+ if arg.type == token.NAME:
43
+ names_inserted.add(arg.value)
44
+ if new_args and new_args[-1].type == token.COMMA:
45
+ del new_args[-1]
46
+ if len(new_args) == 1:
47
+ atom = testlist.parent
48
+ new_args[0].prefix = atom.prefix
49
+ atom.replace(new_args[0])
50
+ else:
51
+ args[:] = new_args
52
+ node.changed()
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_itertools.py ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ Fixer for itertools.(imap|ifilter|izip) --> (map|filter|zip) and
2
+ itertools.ifilterfalse --> itertools.filterfalse (bugs 2360-2363)
3
+
4
+ imports from itertools are fixed in fix_itertools_import.py
5
+
6
+ If itertools is imported as something else (ie: import itertools as it;
7
+ it.izip(spam, eggs)) method calls will not get fixed.
8
+ """
9
+
10
+ # Local imports
11
+ from .. import fixer_base
12
+ from ..fixer_util import Name
13
+
14
+ class FixItertools(fixer_base.BaseFix):
15
+ BM_compatible = True
16
+ it_funcs = "('imap'|'ifilter'|'izip'|'izip_longest'|'ifilterfalse')"
17
+ PATTERN = """
18
+ power< it='itertools'
19
+ trailer<
20
+ dot='.' func=%(it_funcs)s > trailer< '(' [any] ')' > >
21
+ |
22
+ power< func=%(it_funcs)s trailer< '(' [any] ')' > >
23
+ """ %(locals())
24
+
25
+ # Needs to be run after fix_(map|zip|filter)
26
+ run_order = 6
27
+
28
+ def transform(self, node, results):
29
+ prefix = None
30
+ func = results['func'][0]
31
+ if ('it' in results and
32
+ func.value not in (u'ifilterfalse', u'izip_longest')):
33
+ dot, it = (results['dot'], results['it'])
34
+ # Remove the 'itertools'
35
+ prefix = it.prefix
36
+ it.remove()
37
+ # Replace the node which contains ('.', 'function') with the
38
+ # function (to be consistent with the second part of the pattern)
39
+ dot.remove()
40
+ func.parent.replace(func)
41
+
42
+ prefix = prefix or func.prefix
43
+ func.replace(Name(func.value[1:], prefix=prefix))
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_itertools_imports.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """ Fixer for imports of itertools.(imap|ifilter|izip|ifilterfalse) """
2
+
3
+ # Local imports
4
+ from lib2to3 import fixer_base
5
+ from lib2to3.fixer_util import BlankLine, syms, token
6
+
7
+
8
+ class FixItertoolsImports(fixer_base.BaseFix):
9
+ BM_compatible = True
10
+ PATTERN = """
11
+ import_from< 'from' 'itertools' 'import' imports=any >
12
+ """ %(locals())
13
+
14
+ def transform(self, node, results):
15
+ imports = results['imports']
16
+ if imports.type == syms.import_as_name or not imports.children:
17
+ children = [imports]
18
+ else:
19
+ children = imports.children
20
+ for child in children[::2]:
21
+ if child.type == token.NAME:
22
+ member = child.value
23
+ name_node = child
24
+ elif child.type == token.STAR:
25
+ # Just leave the import as is.
26
+ return
27
+ else:
28
+ assert child.type == syms.import_as_name
29
+ name_node = child.children[0]
30
+ member_name = name_node.value
31
+ if member_name in (u'imap', u'izip', u'ifilter'):
32
+ child.value = None
33
+ child.remove()
34
+ elif member_name in (u'ifilterfalse', u'izip_longest'):
35
+ node.changed()
36
+ name_node.value = (u'filterfalse' if member_name[1] == u'f'
37
+ else u'zip_longest')
38
+
39
+ # Make sure the import statement is still sane
40
+ children = imports.children[:] or [imports]
41
+ remove_comma = True
42
+ for child in children:
43
+ if remove_comma and child.type == token.COMMA:
44
+ child.remove()
45
+ else:
46
+ remove_comma ^= True
47
+
48
+ while children and children[-1].type == token.COMMA:
49
+ children.pop().remove()
50
+
51
+ # If there are no imports left, just get rid of the entire statement
52
+ if (not (imports.children or getattr(imports, 'value', None)) or
53
+ imports.parent is None):
54
+ p = node.prefix
55
+ node = BlankLine()
56
+ node.prefix = p
57
+ return node
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_long.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2006 Google, Inc. All Rights Reserved.
2
+ # Licensed to PSF under a Contributor Agreement.
3
+
4
+ """Fixer that turns 'long' into 'int' everywhere.
5
+ """
6
+
7
+ # Local imports
8
+ from lib2to3 import fixer_base
9
+ from lib2to3.fixer_util import is_probably_builtin
10
+
11
+
12
+ class FixLong(fixer_base.BaseFix):
13
+ BM_compatible = True
14
+ PATTERN = "'long'"
15
+
16
+ def transform(self, node, results):
17
+ if is_probably_builtin(node):
18
+ node.value = u"int"
19
+ node.changed()
model/comp_surface/tools/transfer/pdb2pqr-linux-bin64-2.1.1/lib2to3/fixes/fix_map.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright 2007 Google, Inc. All Rights Reserved.
2
+ # Licensed to PSF under a Contributor Agreement.
3
+
4
+ """Fixer that changes map(F, ...) into list(map(F, ...)) unless there
5
+ exists a 'from future_builtins import map' statement in the top-level
6
+ namespace.
7
+
8
+ As a special case, map(None, X) is changed into list(X). (This is
9
+ necessary because the semantics are changed in this case -- the new
10
+ map(None, X) is equivalent to [(x,) for x in X].)
11
+
12
+ We avoid the transformation (except for the special case mentioned
13
+ above) if the map() call is directly contained in iter(<>), list(<>),
14
+ tuple(<>), sorted(<>), ...join(<>), or for V in <>:.
15
+
16
+ NOTE: This is still not correct if the original code was depending on
17
+ map(F, X, Y, ...) to go on until the longest argument is exhausted,
18
+ substituting None for missing values -- like zip(), it now stops as
19
+ soon as the shortest argument is exhausted.
20
+ """
21
+
22
+ # Local imports
23
+ from ..pgen2 import token
24
+ from .. import fixer_base
25
+ from ..fixer_util import Name, Call, ListComp, in_special_context
26
+ from ..pygram import python_symbols as syms
27
+
28
+ class FixMap(fixer_base.ConditionalFix):
29
+ BM_compatible = True
30
+
31
+ PATTERN = """
32
+ map_none=power<
33
+ 'map'
34
+ trailer< '(' arglist< 'None' ',' arg=any [','] > ')' >
35
+ >
36
+ |
37
+ map_lambda=power<
38
+ 'map'
39
+ trailer<
40
+ '('
41
+ arglist<
42
+ lambdef< 'lambda'
43
+ (fp=NAME | vfpdef< '(' fp=NAME ')'> ) ':' xp=any
44
+ >
45
+ ','
46
+ it=any
47
+ >
48
+ ')'
49
+ >
50
+ >
51
+ |
52
+ power<
53
+ 'map' trailer< '(' [arglist=any] ')' >
54
+ >
55
+ """
56
+
57
+ skip_on = 'future_builtins.map'
58
+
59
+ def transform(self, node, results):
60
+ if self.should_skip(node):
61
+ return
62
+
63
+ if node.parent.type == syms.simple_stmt:
64
+ self.warning(node, "You should use a for loop here")
65
+ new = node.clone()
66
+ new.prefix = u""
67
+ new = Call(Name(u"list"), [new])
68
+ elif "map_lambda" in results:
69
+ new = ListComp(results["xp"].clone(),
70
+ results["fp"].clone(),
71
+ results["it"].clone())
72
+ else:
73
+ if "map_none" in results:
74
+ new = results["arg"].clone()
75
+ else:
76
+ if "arglist" in results:
77
+ args = results["arglist"]
78
+ if args.type == syms.arglist and \
79
+ args.children[0].type == token.NAME and \
80
+ args.children[0].value == "None":
81
+ self.warning(node, "cannot convert map(None, ...) "
82
+ "with multiple arguments because map() "
83
+ "now truncates to the shortest sequence")
84
+ return
85
+ if in_special_context(node):
86
+ return None
87
+ new = node.clone()
88
+ new.prefix = u""
89
+ new = Call(Name(u"list"), [new])
90
+ new.prefix = node.prefix
91
+ return new