/usr/lib/python2.7/dist-packages/pymol/externing.py is in pymol 1.8.4.0+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 | #A* -------------------------------------------------------------------
#B* This file contains source code for the PyMOL computer program
#C* Copyright (c) Schrodinger, LLC.
#D* -------------------------------------------------------------------
#E* It is unlawful to modify or remove this copyright notice.
#F* -------------------------------------------------------------------
#G* Please see the accompanying LICENSE file for further information.
#H* -------------------------------------------------------------------
#I* Additional authors of this source file include:
#-*
#-*
#-*
#Z* -------------------------------------------------------------------
from __future__ import print_function
if __name__=='pymol.externing':
import os
import pymol
import string
from . import parsing
import threading
cmd = __import__("sys").modules["pymol.cmd"]
import traceback
from glob import glob
from .cmd import _cmd,lock,unlock,Shortcut,QuietException, \
_feedback,fb_module,fb_mask, exp_path, \
DEFAULT_ERROR, DEFAULT_SUCCESS, _raising, is_ok, is_error
def cd(dir="~",complain=1,quiet=1):
'''
DESCRIPTION
"cd" changes the current working directory.
USAGE
cd <path>
SEE ALSO
pwd, ls, system
'''
dir = exp_path(dir)
try:
os.chdir(dir) # raises on error
if not quiet:
print(" cd: now in %s"%os.getcwd())
except:
if complain:
traceback.print_exc()
return DEFAULT_SUCCESS
def pwd():
'''
DESCRIPTION
Print current working directory.
USAGE
pwd
SEE ALSO
cd, ls, system
'''
print(os.getcwd())
return DEFAULT_SUCCESS
def ls(pattern=None):
'''
DESCRIPTION
List contents of the current working directory.
USAGE
ls [pattern]
dir [pattern]
EXAMPLES
ls
ls *.pml
SEE ALSO
cd, pwd, system
'''
if pattern==None:
pattern = "*"
else:
pattern = exp_path(pattern)
if '*' not in pattern:
lst = glob(os.path.join(pattern, '*'))
else:
lst = []
if not len(lst):
lst = glob(pattern)
if len(lst):
lst.sort()
lst = parsing.list_to_str_list(lst)
for a in lst:
print(a)
else:
print(" ls: Nothing found. Is that a valid path?")
return DEFAULT_SUCCESS
def system(command,async=0,_self=cmd):
'''
DESCRIPTION
"system" executes a command in a subshell under Unix or Windows.
USAGE
system command
PYMOL API
cmd.system(string command,int async=0)
NOTES
async can only be specified from the Python level (not the command language)
if async is 0 (default), then the result code from "system" is returned in r
if async is 1, then the command is run in a separate thread whose object is
returned
SEE ALSO
ls, cd, pwd
'''
r = None
if async:
r = threading.Thread(target=_cmd.system,args=(str(command),1))
r.start()
else:
r = _cmd.system(_self._COb,str(command),0)
return r # special meaning
def paste(_self=cmd): # INTERNAL
r=DEFAULT_SUCCESS
lst = []
if hasattr(pymol,"machine_get_clipboard"):
lst = pymol.machine_get_clipboard()
if len(lst):
new_lst = []
for a in lst:
while len(a):
if ord(a[-1])>32:
break
else:
a=a[:-1]
# if nothing in the queue, this special string is printed; so
# we ignore it
if len(a):
if a=="""PRIMARY selection doesn't exist or form "STRING" not defined""":
new_list = []
else:
new_lst.append(a)
r = _cmd.paste(_self._COb,new_lst)
if _raising(r,_self): raise pymol.CmdException
return r
|