Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
msi.PyDirectory Class Reference
Inheritance diagram for msi.PyDirectory:
Inheritance graph
[legend]
Collaboration diagram for msi.PyDirectory:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def check_unpackaged
def start_component
def start_component
def make_short
def make_short
def add_file
def add_file
def glob
def glob
def remove_pyc
def remove_pyc
def removefile

Public Attributes

 db
 cab
 basedir
 physical
 logical
 component
 short_names
 ids
 keyfiles
 componentflags
 absolute
 unpackaged_files

Detailed Description

By default, all components in the Python installer
can run from source.

Definition at line 899 of file msi.py.


Constructor & Destructor Documentation

def msi.PyDirectory.__init__ (   self,
  args,
  kw 
)

Definition at line 902 of file msi.py.

00902 
00903     def __init__(self, *args, **kw):
00904         if "componentflags" not in kw:
00905             kw['componentflags'] = 2 #msidbComponentAttributesOptional
00906         Directory.__init__(self, *args, **kw)

Here is the caller graph for this function:


Member Function Documentation

def msilib.Directory.add_file (   self,
  file,
  src = None,
  version = None,
  language = None 
) [inherited]
Add a file to the current component of the directory, starting a new one
one if there is no current component. By default, the file name in the source
and the file table will be identical. If the src file is specified, it is
interpreted relative to the current directory. Optionally, a version and a
language can be specified for the entry in the File table.

Definition at line 326 of file __init__.py.

00326 
00327     def add_file(self, file, src=None, version=None, language=None):
00328         """Add a file to the current component of the directory, starting a new one
00329         one if there is no current component. By default, the file name in the source
00330         and the file table will be identical. If the src file is specified, it is
00331         interpreted relative to the current directory. Optionally, a version and a
00332         language can be specified for the entry in the File table."""
00333         if not self.component:
00334             self.start_component(self.logical, current_feature, 0)
00335         if not src:
00336             # Allow relative paths for file if src is not specified
00337             src = file
00338             file = os.path.basename(file)
00339         absolute = os.path.join(self.absolute, src)
00340         assert not re.search(r'[\?|><:/*]"', file) # restrictions on long names
00341         if file in self.keyfiles:
00342             logical = self.keyfiles[file]
00343         else:
00344             logical = None
00345         sequence, logical = self.cab.append(absolute, file, logical)
00346         assert logical not in self.ids
00347         self.ids.add(logical)
00348         short = self.make_short(file)
00349         full = "%s|%s" % (short, file)
00350         filesize = os.stat(absolute).st_size
00351         # constants.msidbFileAttributesVital
00352         # Compressed omitted, since it is the database default
00353         # could add r/o, system, hidden
00354         attributes = 512
00355         add_data(self.db, "File",
00356                         [(logical, self.component, full, filesize, version,
00357                          language, attributes, sequence)])
00358         #if not version:
00359         #    # Add hash if the file is not versioned
00360         #    filehash = FileHash(absolute, 0)
00361         #    add_data(self.db, "MsiFileHash",
00362         #             [(logical, 0, filehash.IntegerData(1),
00363         #               filehash.IntegerData(2), filehash.IntegerData(3),
00364         #               filehash.IntegerData(4))])
00365         # Automatically remove .pyc/.pyo files on uninstall (2)
00366         # XXX: adding so many RemoveFile entries makes installer unbelievably
00367         # slow. So instead, we have to use wildcard remove entries
00368         if file.endswith(".py"):
00369             add_data(self.db, "RemoveFile",
00370                       [(logical+"c", self.component, "%sC|%sc" % (short, file),
00371                         self.logical, 2),
00372                        (logical+"o", self.component, "%sO|%so" % (short, file),
00373                         self.logical, 2)])
00374         return logical

Here is the call graph for this function:

Here is the caller graph for this function:

def msilib.Directory.add_file (   self,
  file,
  src = None,
  version = None,
  language = None 
) [inherited]
Add a file to the current component of the directory, starting a new one
one if there is no current component. By default, the file name in the source
and the file table will be identical. If the src file is specified, it is
interpreted relative to the current directory. Optionally, a version and a
language can be specified for the entry in the File table.

Definition at line 490 of file msilib.py.

00490 
00491     def add_file(self, file, src=None, version=None, language=None):
00492         """Add a file to the current component of the directory, starting a new one
00493         one if there is no current component. By default, the file name in the source
00494         and the file table will be identical. If the src file is specified, it is
00495         interpreted relative to the current directory. Optionally, a version and a
00496         language can be specified for the entry in the File table."""
00497         if not self.component:
00498             self.start_component(self.logical, current_feature)
00499         if not src:
00500             # Allow relative paths for file if src is not specified
00501             src = file
00502             file = os.path.basename(file)
00503         absolute = os.path.join(self.absolute, src)
00504         if absolute.startswith(self.absolute):
00505             # mark file as packaged
00506             relative = absolute[len(self.absolute)+1:]
00507             if relative in self.unpackaged_files:
00508                 self.unpackaged_files.remove(relative)
00509         assert not re.search(r'[\?|><:/*]"', file) # restrictions on long names
00510         if self.keyfiles.has_key(file):
00511             logical = self.keyfiles[file]
00512         else:
00513             logical = None
00514         sequence, logical = self.cab.append(absolute, file, logical)
00515         assert logical not in self.ids
00516         self.ids.add(logical)
00517         short = self.make_short(file)
00518         full = "%s|%s" % (short, file)
00519         filesize = os.stat(absolute).st_size
00520         # constants.msidbFileAttributesVital
00521         # Compressed omitted, since it is the database default
00522         # could add r/o, system, hidden
00523         attributes = 512
00524         add_data(self.db, "File",
00525                         [(logical, self.component, full, filesize, version,
00526                          language, attributes, sequence)])
00527         if not version:
00528             # Add hash if the file is not versioned
00529             filehash = MakeInstaller().FileHash(absolute, 0)
00530             add_data(self.db, "MsiFileHash",
00531                      [(logical, 0, filehash.IntegerData(1),
00532                        filehash.IntegerData(2), filehash.IntegerData(3),
00533                        filehash.IntegerData(4))])
00534         # Automatically remove .pyc/.pyo files on uninstall (2)
00535         # XXX: adding so many RemoveFile entries makes installer unbelievably
00536         # slow. So instead, we have to use wildcard remove entries
00537         # if file.endswith(".py"):
00538         #     add_data(self.db, "RemoveFile",
00539         #              [(logical+"c", self.component, "%sC|%sc" % (short, file),
00540         #                self.logical, 2),
00541         #               (logical+"o", self.component, "%sO|%so" % (short, file),
00542         #                self.logical, 2)])

Here is the call graph for this function:

Definition at line 907 of file msi.py.

00907 
00908     def check_unpackaged(self):
00909         self.unpackaged_files.discard('__pycache__')
00910         self.unpackaged_files.discard('.svn')
00911         if self.unpackaged_files:
00912             print "Warning: Unpackaged files in %s" % self.absolute
00913             print self.unpackaged_files
00914 
00915 # See "File Table", "Component Table", "Directory Table",
# "FeatureComponents Table"
def msilib.Directory.glob (   self,
  pattern,
  exclude = None 
) [inherited]
Add a list of files to the current component as specified in the
glob pattern. Individual files can be excluded in the exclude list.

Definition at line 375 of file __init__.py.

00375 
00376     def glob(self, pattern, exclude = None):
00377         """Add a list of files to the current component as specified in the
00378         glob pattern. Individual files can be excluded in the exclude list."""
00379         files = glob.glob1(self.absolute, pattern)
00380         for f in files:
00381             if exclude and f in exclude: continue
00382             self.add_file(f)
00383         return files

Here is the call graph for this function:

Here is the caller graph for this function:

def msilib.Directory.glob (   self,
  pattern,
  exclude = None 
) [inherited]
Add a list of files to the current component as specified in the
glob pattern. Individual files can be excluded in the exclude list.

Definition at line 543 of file msilib.py.

00543 
00544     def glob(self, pattern, exclude = None):
00545         """Add a list of files to the current component as specified in the
00546         glob pattern. Individual files can be excluded in the exclude list."""
00547         files = glob.glob1(self.absolute, pattern)
00548         for f in files:
00549             if exclude and f in exclude: continue
00550             self.add_file(f)
00551         return files

Here is the call graph for this function:

def msilib.Directory.make_short (   self,
  file 
) [inherited]

Definition at line 285 of file __init__.py.

00285 
00286     def make_short(self, file):
00287         oldfile = file
00288         file = file.replace('+', '_')
00289         file = ''.join(c for c in file if not c in ' "/\[]:;=,')
00290         parts = file.split(".")
00291         if len(parts) > 1:
00292             prefix = "".join(parts[:-1]).upper()
00293             suffix = parts[-1].upper()
00294             if not prefix:
00295                 prefix = suffix
00296                 suffix = None
00297         else:
00298             prefix = file.upper()
00299             suffix = None
00300         if len(parts) < 3 and len(prefix) <= 8 and file == oldfile and (
00301                                                 not suffix or len(suffix) <= 3):
00302             if suffix:
00303                 file = prefix+"."+suffix
00304             else:
00305                 file = prefix
00306         else:
00307             file = None
00308         if file is None or file in self.short_names:
00309             prefix = prefix[:6]
00310             if suffix:
00311                 suffix = suffix[:3]
00312             pos = 1
00313             while 1:
00314                 if suffix:
00315                     file = "%s~%d.%s" % (prefix, pos, suffix)
00316                 else:
00317                     file = "%s~%d" % (prefix, pos)
00318                 if file not in self.short_names: break
00319                 pos += 1
00320                 assert pos < 10000
00321                 if pos in (10, 100, 1000):
00322                     prefix = prefix[:-1]
00323         self.short_names.add(file)
00324         assert not re.search(r'[\?|><:/*"+,;=\[\]]', file) # restrictions on short names
00325         return file

Here is the call graph for this function:

Here is the caller graph for this function:

def msilib.Directory.make_short (   self,
  file 
) [inherited]

Definition at line 458 of file msilib.py.

00458 
00459     def make_short(self, file):
00460         file = re.sub(r'[\?|><:/*"+,;=\[\]]', '_', file) # restrictions on short names
00461         parts = file.split(".")
00462         if len(parts)>1:
00463             suffix = parts[-1].upper()
00464         else:
00465             suffix = None
00466         prefix = parts[0].upper()
00467         if len(prefix) <= 8 and (not suffix or len(suffix)<=3):
00468             if suffix:
00469                 file = prefix+"."+suffix
00470             else:
00471                 file = prefix
00472             assert file not in self.short_names
00473         else:
00474             prefix = prefix[:6]
00475             if suffix:
00476                 suffix = suffix[:3]
00477             pos = 1
00478             while 1:
00479                 if suffix:
00480                     file = "%s~%d.%s" % (prefix, pos, suffix)
00481                 else:
00482                     file = "%s~%d" % (prefix, pos)
00483                 if file not in self.short_names: break
00484                 pos += 1
00485                 assert pos < 10000
00486                 if pos in (10, 100, 1000):
00487                     prefix = prefix[:-1]
00488         self.short_names.add(file)
00489         return file

Here is the call graph for this function:

def msilib.Directory.remove_pyc (   self) [inherited]

Definition at line 384 of file __init__.py.

00384 
00385     def remove_pyc(self):
00386         "Remove .pyc/.pyo files on uninstall"
00387         add_data(self.db, "RemoveFile",
00388                  [(self.component+"c", self.component, "*.pyc", self.logical, 2),
00389                   (self.component+"o", self.component, "*.pyo", self.logical, 2)])

Here is the call graph for this function:

Here is the caller graph for this function:

def msilib.Directory.remove_pyc (   self) [inherited]

Definition at line 552 of file msilib.py.

00552 
00553     def remove_pyc(self):
00554         "Remove .pyc/.pyo files from __pycache__ on uninstall"
00555         directory = self.logical + "_pycache"
00556         add_data(self.db, "Directory", [(directory, self.logical, "__PYCA~1|__pycache__")])
00557         flags = 256 if Win64 else 0
00558         add_data(self.db, "Component",
00559                 [(directory, gen_uuid(), directory, flags, None, None)])
00560         add_data(self.db, "FeatureComponents", [(current_feature.id, directory)])
00561         add_data(self.db, "CreateFolder", [(directory, directory)])
00562         add_data(self.db, "RemoveFile",
00563                  [(self.component, self.component, "*.*", directory, 2),
00564                  ])

Here is the call graph for this function:

def msilib.Directory.removefile (   self,
  key,
  pattern 
) [inherited]

Definition at line 565 of file msilib.py.

00565 
00566     def removefile(self, key, pattern):
00567         "Add a RemoveFile entry"
00568         add_data(self.db, "RemoveFile", [(self.component+key, self.component, pattern, self.logical, 2)])
00569 

Here is the call graph for this function:

def msilib.Directory.start_component (   self,
  component = None,
  feature = None,
  flags = None,
  keyfile = None,
  uuid = None 
) [inherited]
Add an entry to the Component table, and make this component the current for this
directory. If no component name is given, the directory name is used. If no feature
is given, the current feature is used. If no flags are given, the directory's default
flags are used. If no keyfile is given, the KeyPath is left null in the Component
table.

Definition at line 256 of file __init__.py.

00256 
00257     def start_component(self, component = None, feature = None, flags = None, keyfile = None, uuid=None):
00258         """Add an entry to the Component table, and make this component the current for this
00259         directory. If no component name is given, the directory name is used. If no feature
00260         is given, the current feature is used. If no flags are given, the directory's default
00261         flags are used. If no keyfile is given, the KeyPath is left null in the Component
00262         table."""
00263         if flags is None:
00264             flags = self.componentflags
00265         if uuid is None:
00266             uuid = gen_uuid()
00267         else:
00268             uuid = uuid.upper()
00269         if component is None:
00270             component = self.logical
00271         self.component = component
00272         if Win64:
00273             flags |= 256
00274         if keyfile:
00275             keyid = self.cab.gen_id(self.absolute, keyfile)
00276             self.keyfiles[keyfile] = keyid
00277         else:
00278             keyid = None
00279         add_data(self.db, "Component",
00280                         [(component, uuid, self.logical, flags, None, keyid)])
00281         if feature is None:
00282             feature = current_feature
00283         add_data(self.db, "FeatureComponents",
00284                         [(feature.id, component)])

Here is the call graph for this function:

Here is the caller graph for this function:

def msilib.Directory.start_component (   self,
  component = None,
  feature = None,
  flags = None,
  keyfile = None,
  uuid = None 
) [inherited]
Add an entry to the Component table, and make this component the current for this
directory. If no component name is given, the directory name is used. If no feature
is given, the current feature is used. If no flags are given, the directory's default
flags are used. If no keyfile is given, the KeyPath is left null in the Component
table.

Definition at line 429 of file msilib.py.

00429 
00430     def start_component(self, component = None, feature = None, flags = None, keyfile = None, uuid=None):
00431         """Add an entry to the Component table, and make this component the current for this
00432         directory. If no component name is given, the directory name is used. If no feature
00433         is given, the current feature is used. If no flags are given, the directory's default
00434         flags are used. If no keyfile is given, the KeyPath is left null in the Component
00435         table."""
00436         if flags is None:
00437             flags = self.componentflags
00438         if uuid is None:
00439             uuid = gen_uuid()
00440         else:
00441             uuid = uuid.upper()
00442         if component is None:
00443             component = self.logical
00444         self.component = component
00445         if Win64:
00446             flags |= 256
00447         if keyfile:
00448             keyid = self.cab.gen_id(self.absolute, keyfile)
00449             self.keyfiles[keyfile] = keyid
00450         else:
00451             keyid = None
00452         add_data(self.db, "Component",
00453                         [(component, uuid, self.logical, flags, None, keyid)])
00454         if feature is None:
00455             feature = current_feature
00456         add_data(self.db, "FeatureComponents",
00457                         [(feature.id, component)])

Here is the call graph for this function:


Member Data Documentation

Definition at line 249 of file __init__.py.

Definition at line 240 of file __init__.py.

msilib.Directory.cab [inherited]

Definition at line 239 of file __init__.py.

Definition at line 243 of file __init__.py.

Definition at line 247 of file __init__.py.

msilib.Directory.db [inherited]

Definition at line 238 of file __init__.py.

msilib.Directory.ids [inherited]

Definition at line 245 of file __init__.py.

Definition at line 246 of file __init__.py.

Definition at line 242 of file __init__.py.

Definition at line 241 of file __init__.py.

Definition at line 244 of file __init__.py.

Definition at line 423 of file msilib.py.


The documentation for this class was generated from the following file: