Help Deciphering Code

Terry Reedy tjreedy at udel.edu
Mon Mar 5 13:32:39 EST 2007


"Bryan Leber" <btl at fischerinternational.com> wrote in message 
news:3671C2002ECC9149B2B5509290F533A678FA30 at fiscex.FISCHERINTERNATIONAL.COM...

I am learning python and I am having to make some changes on an existing
python script. What happens is that one scripts creates an xml document
that looks like this:

<CommitOperation
file="IPM2.1/Identity/IdentityWebApp/Source/com/fisc/prioss/dataservice/
component/profile ProfileUtil.java" message="PATCH_BRANCH: N/A
BUG_NUMBER: N/A FEATURE_AFFECTED: N/A OVERVIEW: Changes for not
including the product configuration account, idmconfig in searches. ""
module="IPM2.1"

The first attribute "file" as you can see shows the path where the file
is and then a space and the actual file name. This is put into a
variable named file. Then in the script, there is a method called that
passes in this variable. The first line in the method called is this:
          reg = re.compile(r'[\\]+[ ]+')
I'm not 100% sure what this is doing, but I believe it is trying to
parse the file variable so that you only get the file name. It is weird
because this had been working just fine until about 2 months ago then it
just started not parsing anything. If anyone can help please help:-)

==================================================
I have no idea what changed, but splitting the file var into its two 
components is trivial:

>>> "IPM2.1/Identity/IdentityWebApp/Source/com/fisc/prioss/dataservice/component/profile 
>>> ProfileUtil.java".split()

['IPM2.1/Identity/IdentityWebApp/Source/com/fisc/prioss/dataservice/component/profile', 
'ProfileUtil.java']

If the ' ' were a '/' instead, then the os.path module has a function for 
splitting off the last component, the file name.

Terry Jan Reedy







More information about the Python-list mailing list