;๒ _้Cc@sdZdkZdkZdkZdkZdkZdklZdklZdkl Z dkl Z dZ ei dƒZ defd „ƒYZd „Zd „Zed „Zd „Zd„Zd„Zd„Zd„ZeidƒiZd„Zd„Zd„ZdS(sgSupport for handling package configuration files. The package configuration files handled by this module provide information about the software and documentation contents of a distribution component. The same kinds of information can be described for any component, with the exception that extensions only make sense for package components. There are only a few types of information which can appear in a package configuration file; the file is intended to describe what a package provides that is not a module or data file. The three types of things which can be listed in the file are: - scripts - documentation - extensions The scripts and documentation files are listed very simply:: documentation *.txt documentation apiref.pdf script scritps/* The value to the right of the identifying keyword is a portable glob pattern, where *portable* here means the pattern uses the POSIX notation. Path components should be separated by forward slashes (like all paths used with `distutils`), ``?`` can be replaced by any single character, and ``*`` can be replaced by zero or more characters. :Variables: - `PACKAGE_CONF`: Name of the package information file. :Groups: - `Public interface`: loadCollectionInfo loadPackageInfo - `Helper functions`: create_extension expand_globs read_package_info - `Datatype functions`: cpp_definition cpp_names path_ref N(sStringIO(s cfgparser(sdist(surlutilss SETUP.cfgs package.xmlsHeadercBs tZdZd„Zd„ZRS(sAInformation about a header file and the package that provides it.cCs||_||_dS(N(spackagesselfspath(sselfspackagespath((sS/mnt/gmirror/ports/devel/py-zconfig/work/ZConfig-2.3.1/Support/zpkgsetup/package.pys__init__Ms cCsd|i|ifSdS(Ns(sselfspackagespath(sself((sS/mnt/gmirror/ports/devel/py-zconfig/work/ZConfig-2.3.1/Support/zpkgsetup/package.pys__repr__Qs(s__name__s __module__s__doc__s__init__s__repr__(((sS/mnt/gmirror/ports/devel/py-zconfig/work/ZConfig-2.3.1/Support/zpkgsetup/package.pysHeaderJs  cCs†t||ƒ}gi}|iD]}|t|||ƒƒq ~|_gi}|i D]}|t ||ƒƒqY~|_ |SdS(s&Load package information for a Python package. :return: Package information object. :Parameters: - `pkgname`: Full name of the Python package to which the information being read applies. This is needed to construct Extension objects properly. - `directory`: Directory containing the package's __init__.py file. - `reldir`: Relative directory path with which file names from the information file will be joined. This should be in POSIX notation. It will not be used to locate files. N(sread_package_infos directorysreldirspkginfosappends_[1]s extensionssextscreate_extensionspkgnamesheaderspathsHeaderspackage_headers(spkgnames directorysreldirspkginfos_[1]sextspath((sS/mnt/gmirror/ports/devel/py-zconfig/work/ZConfig-2.3.1/Support/zpkgsetup/package.pysloadPackageInfoUs 96cCs†t||ƒ}gi}|iD]}|t|t |ƒƒq ~|_gi}|i D]}|t t |ƒƒqY~|_ |SdS(sqLoad package information for a collection. :return: Package information object. :Parameters: - `directory`: Directory containing the collection's files. - `reldir`: Relative directory path with which file names from the information file will be joined. This should be in POSIX notation. It will not be used to locate files. N(sread_package_infos directorysreldirspkginfosappends_[1]s extensionssextscreate_extensionsNonesheaderspathsHeaderspackage_headers(s directorysreldirspkginfos_[1]sextspath((sS/mnt/gmirror/ports/devel/py-zconfig/work/ZConfig-2.3.1/Support/zpkgsetup/package.pysloadCollectionInfols 96c Cstii|tƒ}tii|ƒo:tii|ƒ}tit i |ƒƒ} t |ƒ} nd} tdƒ} z"titƒ| | ƒ\}}Wd| iƒXx*|iD]\}}t|||ƒ|(qฎWt|||iƒ|_t|||iƒ|_t|||iƒ|_h}x-|iD]"\} }t||| ||ƒq)Wd|jo|dgjo |d=n|i ƒ|_|SdS(s๗Read the package information file from a specified directory. :return: Package information object. :Parameters: - `directory`: Directory containing the collection's files. - `reldir`: Relative directory path with which file names from the information file will be joined. This should be in POSIX notation. It will not be used to locate files. It may be omitted or None; if so, filenames are not 'relocated' relative to where they are found. s sNs.(!sosspathsjoins directorys PACKAGE_CONFsexistssrealpathsurlutilssfile_urlsurllibs pathname2urlsurlsopensfsStringIOs cfgparsersloadConfigFiles get_schemaspkginfos_scloses data_filessnames expand_globssreldirs documentationsheadersscriptsdatamapsdirspathss expand_datasitems( s directorysreldirspaths data_filesspathsspkginfosdatamaps_snamesfsurlsdir((sS/mnt/gmirror/ports/devel/py-zconfig/work/ZConfig-2.3.1/Support/zpkgsetup/package.pysread_package_info€s6  "     c Csti|ƒ}|i|gƒ}|oti|dƒ} nd} xะ|D]ศ}|t | ƒi dt iƒ}t ii||ƒ} t ii| ƒo|i|ƒqKt ii| ƒ}t||ti||ƒgi} t i| ƒD]} | ti|| ƒƒq๊~ |ƒqKWdS(Nss/(s posixpathsnormpaths targetdirsdatamaps setdefaultsLsreldirsjoinsprefixspathsssrcslensreplacesossseps localpathspaths directorysfullpathsisfilesappendsbasenames expand_datas_[1]slistdirsname( s directorysreldirs targetdirspathssdatamapssrcsbasenamesLs localpaths_[1]sprefixsfullpathsname((sS/mnt/gmirror/ports/devel/py-zconfig/work/ZConfig-2.3.1/Support/zpkgsetup/package.pys expand_dataฒs9cCsjh}|od||iƒf|dgi}|iD]}|ti ||ƒƒq่~|d c Cs g}tiƒ}ti|ƒzำxฬ|D]ฤ}|idti ƒ}t i |ƒ}| ot d|ƒ‚ngi}|D]} || iti dƒƒq}~}|o7gi}|D]} |ti|| ƒƒqบ~}n||7}q)WWdti|ƒX|SdS(sExpand glob patterns for directory. :Parameters: - `directory`: The path to the directory to which the glob patterns are relative to. - `reldir`: Base directory to use for returning glob expansions. This should be a relative path in POSIX notation. This is not used for locating files. - `globlist`: List of glob patterns in POSIX notation. The patterns may refer to child directories of `directory`. :return: List of expansions in POSIX notation, using `reldir` as the base directory. Note that `directory` and `reldir` are two different names for the same directory. :warning: This function is not thread safe, as it changes the current working directory while it is running. s/s+filename pattern %r doesn't match any filesN(sresultssossgetcwdspwdschdirs directorysgloblistsgsreplacessepsgssglobs filenamess ValueErrorsappends_[1]sfnsreldirs posixpathsjoin( s directorysreldirsgloblistsgssgsresultss filenamess_[1]spwdsfn((sS/mnt/gmirror/ports/devel/py-zconfig/work/ZConfig-2.3.1/Support/zpkgsetup/package.pys expand_globss$  67cCs‚d|jo4|iddƒ\}}|iƒ}|iƒ}n |}t}t|ƒtjotd|ƒ‚n||fSdS(suReturn a 2-tuple representing a CPP #define. :rtype: (str, str or None) The first element of the tuple is the name to define, and the second is the value to use as the replacement text. In the input, the two parts should be separated by an equal sign. >>> cpp_definition('NAME=VALUE') ('NAME', 'VALUE') >>> cpp_definition('NAME=') ('NAME', '') Whitespace around the equal sign are ignored: >>> cpp_definition('NAME =\tVALUE') ('NAME', 'VALUE') If there is no equal sign, and defininition with no replacement text is used (equivalent to '#define NAME'): >>> cpp_definition('NAME') ('NAME', None) ValueError is raised if there is an error in the input: >>> cpp_definition('not-a-cpp-symbol') Traceback (most recent call last): ... ValueError: not a valid C identifier: 'not-a-cpp-symbol' s=isnot a valid C identifier: %rN( ssssplitsnamesvaluesrstripslstripsNones_cpp_ident_matchs ValueError(sssnamesvalue((sS/mnt/gmirror/ports/devel/py-zconfig/work/ZConfig-2.3.1/Support/zpkgsetup/package.pyscpp_definition3s   cCsL|iƒ}x5|D]-}t|ƒtjotd|ƒ‚qqW|SdS(sKReturn a list of CPP symbols from a string. :rtype: [str, ...] >>> cpp_names('NAME') ['NAME'] >>> cpp_names('NAME1 NAME_2 A_B_C A123') ['NAME1', 'NAME_2', 'A_B_C', 'A123'] If something is included which is not a valid identifier for CPP, ValueError is raised: >>> cpp_names('not-really!') Traceback (most recent call last): ... ValueError: not a valid C identifier: 'not-really!' >>> cpp_names('NAME ANOTHER not-really!') Traceback (most recent call last): ... ValueError: not a valid C identifier: 'not-really!' snot a valid C identifier: %rN(ssssplitsnamessnames_cpp_ident_matchsNones ValueError(sssnamesnames((sS/mnt/gmirror/ports/devel/py-zconfig/work/ZConfig-2.3.1/Support/zpkgsetup/package.pys cpp_names`s s[A-Za-z_][A-Za-z_0-9]*$cCs|otdƒ‚n|SdS(Ns,data-file specifications may not have values(sss ValueError(ss((sS/mnt/gmirror/ports/devel/py-zconfig/work/ZConfig-2.3.1/Support/zpkgsetup/package.pys empty_stringscCsฒ| otdƒ‚n|idƒdjotd|ƒ‚nti|ƒ}|d djotd|ƒ‚n|idƒ}|ddjotd |ƒ‚n|Sd S( s"Datatype for a local path reference. :rtype: str >>> path_ref('README.txt') 'README.txt' >>> path_ref('./README.txt') 'README.txt' >>> path_ref('foo/bar/file.txt') 'foo/bar/file.txt' If a reference is not a relative path, ValueError is raised: >>> path_ref('/absolute/path') Traceback (most recent call last): ... ValueError: absolute paths are not allowed: '/absolute/path' >>> path_ref('/') Traceback (most recent call last): ... ValueError: absolute paths are not allowed: '/' References which contain Windows drive letters are not allowed: >>> path_ref('c:README.txt') Traceback (most recent call last): ... ValueError: Windows drive letters are not allowed: 'c:README.txt' If a reference is relative but points outside the local directory hierarchy, ValueError is raised: >>> path_ref('../somefile') Traceback (most recent call last): ... ValueError: relative paths may not point outside the containing tree: '../somefile' s path references may not be emptys:is)Windows drive letters are not allowed: %rs/s"absolute paths are not allowed: %ris..s<relative paths may not point outside the containing tree: %rN(sss ValueErrorsfinds posixpathsnormpathspssplitsparts(ssspsparts((sS/mnt/gmirror/ports/devel/py-zconfig/work/ZConfig-2.3.1/Support/zpkgsetup/package.pyspath_ref‡s'cCs,ti|iƒƒ}||iiƒfSdS(N(s posixpathsnormpathssectionsgetSectionNamesnamesfilesskeys(ssectionsname((sS/mnt/gmirror/ports/devel/py-zconfig/work/ZConfig-2.3.1/Support/zpkgsetup/package.pysdata_file_sectionพs(s__doc__sglobsoss posixpathsresurllibsStringIOs zpkgsetups cfgparsersdistsurlutilss PACKAGE_CONFscachedSchemaLoaders get_schemasobjectsHeadersloadPackageInfosloadCollectionInfosNonesread_package_infos expand_datascreate_extensions expand_globsscpp_definitions cpp_namesscompilesmatchs_cpp_ident_matchs empty_stringspath_refsdata_file_section(sdistsread_package_infoscpp_definitionscreate_extensionsdata_file_sectionsloadCollectionInfos posixpaths_cpp_ident_matchsurllibsrespath_refsloadPackageInfosglobs cpp_namess PACKAGE_CONFs get_schemasurlutilssStringIOsoss cfgparsers expand_globss empty_stringsHeaders expand_data((sS/mnt/gmirror/ports/devel/py-zconfig/work/ZConfig-2.3.1/Support/zpkgsetup/package.pys?6s0            2 1 % + -   7