On 2006-08-17, Sybren Stuvel <[EMAIL PROTECTED]> wrote:
> Dennis Lee Bieber enlightened us with:
>> What happens when you get a pathname that looks like:
>>
>> \\who\cares\common.exe\program.exe
>
> Is that possible on Windows?
Sure. Why wouldn't it be?
> At one point, I named a directory "
On 17/08/06, Sybren Stuvel <[EMAIL PROTECTED]> wrote:
> Dennis Lee Bieber enlightened us with:
> > What happens when you get a pathname that looks like:
> >
> > \\who\cares\common.exe\program.exe
>
> Is that possible on Windows? At one point, I named a directory
> "www.something.com" and then
Hitesh, You might want to try this:
>>> tricky_path_name = '\\serverName\\C:\\exe files\\example.exe -u ABC -g DEF'
>>> import SE
>>> Editor = SE.SE ('C:=C$: "exe -=exe"')
>>> edited_path_name = Editor (tricky_path_name)
>>> print edited_path_name# See what it did
\serverName\C$:\exe fil
There was a typo. I corrected it.
Hitesh wrote:
> How about this:
>
> def TruncateString(s, Tindex):
> return string.ljust(s,Tindex){:Tindex]
>
>
> s = '\\serverName\\C:\\Folder Name1\\FolderName2\\example.exe -u ABC -g
>
> XYZ'
> try:
> Sindex = s.find(".exe")
> if Sindex > 0:
>
How about this:
def TruncateString(s, Tindex):
return string.ljust(s,Tindex){:Tindex]
s = '\\serverName\\C:\\Folder Name1\\FolderName2\\example.exe -u ABC -g
XYZ'
try:
Sindex = s.find(".exe")
if Sindex > 0:
Sindex = Tindex + 4
s1 = TruncateString(s, Sindex)
except:
I post a crappy solution but I can add few more stuff to make it fail
proof.
i.e. I can search for ".exe -u"
But if someone names folder like "folder.exe u". This script could
fail.
Or if in padded garbase I get ".exe u"
These are two known issues I have to takcle.
Thanks everyone for your help.
On 2006-08-16, Hitesh <[EMAIL PROTECTED]> wrote:
>
> Here is a mediocare solution.
>
> def TruncateString(s, Tindex):
> return string.ljust(s,Tindex){:Tindex]
>
> s = '\\serverName\\C:\\Folder Name1\\FolderName2\\example.exe -u ABC -g
> XYZ'
> Sindex = s.find(".exe")
> Sindex = Tindex +4
> s1 =
On 2006-08-16, Hitesh <[EMAIL PROTECTED]> wrote:
> anything after .exe should be truncated (or deleted).
That will fail if any directory names contain the string
".exe", but if that's what you want, it's trivial enough:
for s in ["asdfasdf.exe -u", "soemthing/else",
"asdf.exe/qwerqwer/qwerqwer.
Here is a mediocare solution.
def TruncateString(s, Tindex):
return string.ljust(s,Tindex){:Tindex]
s = '\\serverName\\C:\\Folder Name1\\FolderName2\\example.exe -u ABC -g
XYZ'
Sindex = s.find(".exe")
Sindex = Tindex +4
s1 = TruncateString(s, Sindex)
Hitesh wrote:
> anything after .exe sh
anything after .exe should be truncated (or deleted).
Grant Edwards wrote:
> On 2006-08-16, Hitesh <[EMAIL PROTECTED]> wrote:
>
> > That might work but what if I get (in future) a path name where
> > foldername (and in windows it is very common, someone might name a
> > folder something like "Sc
On 2006-08-16, Hitesh <[EMAIL PROTECTED]> wrote:
> That might work but what if I get (in future) a path name where
> foldername (and in windows it is very common, someone might name a
> folder something like "Screw You") with space?
You must come up with a rigorous specification for what is and
i
>>> s = '\\serverName\C:\Folder Name1\FolderName2\example.exe -u ABC -g XYZ'
>>> p = s.split(" ", 1)[0]
>>> p
'\\serverName\\C:\\Folder'
hj
Larry Bates wrote:
> Sounds like you can split the string on a space and throw
> away the right side:
>
> s='\\serverName\C:\FolderName1\FolderName2\exampl
That might work but what if I get (in future) a path name where
foldername (and in windows it is very common, someone might name a
folder something like "Screw You") with space?
Larry Bates wrote:
> Sounds like you can split the string on a space and throw
> away the right side:
>
> s='\\server
Sounds like you can split the string on a space and throw
away the right side:
s='\\serverName\C:\FolderName1\FolderName2\example.exe' -u ABC -g XYZ
p=s.split(" ", 1)[0]
print p
'\\serverName\C:\FolderName1\FolderName2\example.exe'
Larry Bates
Hitesh wrote:
>
>
> Hi,
>
> Everything is workin
Hi,
Everything is working fine and dandy but I ran across another issue
here.
Some of the path comes with some extra chars padded at the end.
i.e.
'\\serverName\C:\FolderName1\FolderName2\example.exe' -u ABC -g XYZ
abcdef
Now those padded chars are not constant all the time. It can be
anythin
On 16 Aug 2006 10:30:26 -0700, Hitesh <[EMAIL PROTECTED]> wrote:
>
> Thank you all it worked!.
>
> Tim,
>
> > modRows = ['\\'+itm[0].replace(":", "$") for itm in rows]
>
> What are those two forward slashes for?
Hi Hitesh,
\ is an escape character, it can give unexpected results depending
on t
Thank you all it worked!.
Tim,
> modRows = ['\\'+itm[0].replace(":", "$") for itm in rows]
What are those two forward slashes for?
I had to remove them otherwise I was getting output like '\\'
inside list or if I print I was getting like \\\
Thanks,
hj
Tim Williams wrote:
> On 16/08/06,
On 16/08/06, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On 16 Aug 2006 09:00:57 -0700, "Hitesh" <[EMAIL PROTECTED]> declaimed
> the following in comp.lang.python:
>
> >
> > Thank you Fredrik. That works for a string.
> > But I am getting list of tuples from DB.
> >
> > rows = [('\\serverName\C:
In <[EMAIL PROTECTED]>, Hitesh wrote:
> That works for a string.
> But I am getting list of tuples from DB.
>
> rows = [('\\serverName\C:\FolderName1\FolderName2\example.exe',),
> ('\\serverName\C:\FolderName1\FolderName2\example2.exe',),
> ('\\serverName\C:\FolderName1\FolderName2\example3.exe',
Thank you Fredrik. That works for a string.
But I am getting list of tuples from DB.
rows = [('\\serverName\C:\FolderName1\FolderName2\example.exe',),
('\\serverName\C:\FolderName1\FolderName2\example2.exe',),
('\\serverName\C:\FolderName1\FolderName2\example3.exe',),
('\\serverName\C:\FolderName
"Hitesh" wrote:
> I get path strings from a DB like:
>
> \\serverName\C:\FolderName1\FolderName2\example.exe
>
> I am writing a script that can give me access to that exe file.
> But problem is that string is not universal path, I need to add C$.
> Any idea how I can add $ char in that string.
> S
21 matches
Mail list logo