2005年07月16日 星期六 23:59
不同的FTP server返回的格式是不同的,您考虑过没有? 在 05-7-16,Leo Jay<python.leojay at gmail.com> 写道: > 谢谢大家的帮忙,我自己写了解析的部分, > 把我的代码片断分享给大家,希望有用: > > fileLinePattern = re.compile( > r'^(?P.)(?P > r'(?P.{9})\s+(?P \d*)\s*' \S+)\s+(?P > r'(?P\S+)\s+(?P \d+)\s+' ...\s+\d+\s+[\d:]+)\s+(?P > r'( -> (?P([^ ]|\\ )*?)' [^\r]*))?\r?$' > ) > > # 传入一行,返回一个字典,记录文件的信息 > def parseDirectoryLine(line): > match = fileLinePattern.match(line) > if match is None: > return None > else: > d = match.groupdict() > d['filename'] = d['filename'].replace(r'\ ', ' ') > d['nlinks'] = int(d['nlinks']) > d['size'] = int(d['size']) > > if d['date'][-3] == ':': > t = time.strptime(d['date'],'%b %d %H:%M') > t = datetime.datetime(datetime.datetime.today().year, > t[1], t[2], t[3], t[4] ) > else: > t = time.strptime(d['date'],'%b %d %Y') > t = datetime.datetime(t[0],t[1],t[2]) > > d['date'] = t > > if d['linktarget']: > d['linktarget'] = d['linktarget'].replace(r'\ ', ' ') > > files.append(d) > return d > > On 7/16/05, Jason Liu <telecomliu at gmail.com> wrote: > > 网上有一个解析FTP返回信息的C程序,我学习python时把它用python重新写了一遍。你看看合用不合用,里面应该有解析时间的能力。如果有错误也麻烦你指出来。 > > > > 程序在附件里。 > > > > 基本用法是 > > ftpparse(info) ->ftpitem > > info 是list返回的单个字符串。 > > ftpitem是包含所有解析信息的list,内容与下面的C struct对应 > > > > struct ftpparse { > > char *name; /* not necessarily 0-terminated */ > > int flagtrycwd; /* 0 if cwd is definitely pointless, 1 otherwise */ > > int flagtryretr; /* 0 if retr is definitely pointless, 1 otherwise */ > > long size; /* number of octets */ > > int mtimetype; > > time_t mtime; /* modification time */ > > int idtype; > > char *id; /* not necessarily 0-terminated */ > > } ; > > > > > > > -- > Best Regards, > Leo Jay >
2005年07月17日 星期日 09:23
没有。手上可以给我试的FTP就一个,所以…… 都会有哪些日期的可能呢? On 7/16/05, Jason Liu <telecomliu at gmail.com> wrote: > 不同的FTP server返回的格式是不同的,您考虑过没有? > > 在 05-7-16,Leo Jay<python.leojay at gmail.com> 写道: > > 谢谢大家的帮忙,我自己写了解析的部分, > > 把我的代码片断分享给大家,希望有用: > > > > fileLinePattern = re.compile( > > r'^(?P.)(?P > > r'(?P.{9})\s+(?P \d*)\s*' \S+)\s+(?P > > r'(?P\S+)\s+(?P \d+)\s+' ...\s+\d+\s+[\d:]+)\s+(?P > > r'( -> (?P([^ ]|\\ )*?)' [^\r]*))?\r?$' > > ) > > > > # 传入一行,返回一个字典,记录文件的信息 > > def parseDirectoryLine(line): > > match = fileLinePattern.match(line) > > if match is None: > > return None > > else: > > d = match.groupdict() > > d['filename'] = d['filename'].replace(r'\ ', ' ') > > d['nlinks'] = int(d['nlinks']) > > d['size'] = int(d['size']) > > > > if d['date'][-3] == ':': > > t = time.strptime(d['date'],'%b %d %H:%M') > > t = datetime.datetime(datetime.datetime.today().year, > > t[1], t[2], t[3], t[4] ) > > else: > > t = time.strptime(d['date'],'%b %d %Y') > > t = datetime.datetime(t[0],t[1],t[2]) > > > > d['date'] = t > > > > if d['linktarget']: > > d['linktarget'] = d['linktarget'].replace(r'\ ', ' ') > > > > files.append(d) > > return d > > > > On 7/16/05, Jason Liu <telecomliu at gmail.com> wrote: > > > 网上有一个解析FTP返回信息的C程序,我学习python时把它用python重新写了一遍。你看看合用不合用,里面应该有解析时间的能力。如果有错误也麻烦你指出来。 > > > > > > 程序在附件里。 > > > > > > 基本用法是 > > > ftpparse(info) ->ftpitem > > > info 是list返回的单个字符串。 > > > ftpitem是包含所有解析信息的list,内容与下面的C struct对应 > > > > > > struct ftpparse { > > > char *name; /* not necessarily 0-terminated */ > > > int flagtrycwd; /* 0 if cwd is definitely pointless, 1 otherwise */ > > > int flagtryretr; /* 0 if retr is definitely pointless, 1 otherwise */ > > > long size; /* number of octets */ > > > int mtimetype; > > > time_t mtime; /* modification time */ > > > int idtype; > > > char *id; /* not necessarily 0-terminated */ > > > } ; > > > > > > > > > > > > -- > > Best Regards, > > Leo Jay > > > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > > > -- Best Regards, Leo Jay
2005年07月17日 星期日 13:56
IIS 好象默认的是 msdos 格式 和传统的 unix 格式不一样 Leo Jay <python.leojay at gmail.com> wrote: > 没有。手上可以给我试的FTP就一个,所以…… > 都会有哪些日期的可能呢? > > > On 7/16/05, Jason Liu <telecomliu at gmail.com> wrote: >> 不同的FTP server返回的格式是不同的,您考虑过没有? >> >> 在 05-7-16,Leo Jay<python.leojay at gmail.com> 写道: >> > 谢谢大家的帮忙,我自己写了解析的部分, >> > 把我的代码片断分享给大家,希望有用: >> > >> > fileLinePattern = re.compile( >> > r'^(?P.)(?P >> > r'(?P.{9})\s+(?P \d*)\s*' \S+)\s+(?P >> > r'(?P\S+)\s+(?P \d+)\s+' ...\s+\d+\s+[\d:]+)\s+(?P >> > r'( -> (?P([^ ]|\\ )*?)' [^\r]*))?\r?$' >> > ) >> > >> > # 传入一行,返回一个字典,记录文件的信息 >> > def parseDirectoryLine(line): >> > match = fileLinePattern.match(line) >> > if match is None: >> > return None >> > else: >> > d = match.groupdict() >> > d['filename'] = d['filename'].replace(r'\ ', ' ') >> > d['nlinks'] = int(d['nlinks']) >> > d['size'] = int(d['size']) >> > >> > if d['date'][-3] == ':': >> > t = time.strptime(d['date'],'%b %d %H:%M') >> > t = datetime.datetime(datetime.datetime.today().year, >> > t[1], t[2], t[3], t[4] ) >> > else: >> > t = time.strptime(d['date'],'%b %d %Y') >> > t = datetime.datetime(t[0],t[1],t[2]) >> > >> > d['date'] = t >> > >> > if d['linktarget']: >> > d['linktarget'] = d['linktarget'].replace(r'\ ', ' ') >> > >> > files.append(d) >> > return d >> > >> > On 7/16/05, Jason Liu <telecomliu at gmail.com> wrote: >> > > 网上有一个解析FTP返回信息的C程序,我学习python时把它用python重新写了一遍。你看看合用不合用,里面应该有解析时间的能力。如果有错误也麻烦你指出来。 >> > > >> > > 程序在附件里。 >> > > >> > > 基本用法是 >> > > ftpparse(info) ->ftpitem >> > > info 是list返回的单个字符串。 >> > > ftpitem是包含所有解析信息的list,内容与下面的C struct对应 >> > > >> > > struct ftpparse { >> > > char *name; /* not necessarily 0-terminated */ >> > > int flagtrycwd; /* 0 if cwd is definitely pointless, 1 otherwise */ >> > > int flagtryretr; /* 0 if retr is definitely pointless, 1 otherwise */ >> > > long size; /* number of octets */ >> > > int mtimetype; >> > > time_t mtime; /* modification time */ >> > > int idtype; >> > > char *id; /* not necessarily 0-terminated */ >> > > } ; >> > > >> > > >> > >> > >> > -- >> > Best Regards, >> > Leo Jay >> > >> >> _______________________________________________ >> python-chinese list >> python-chinese at lists.python.cn >> http://python.cn/mailman/listinfo/python-chinese >> >> >> > > > -- > Best Regards, > Leo Jay > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese -- Dryice @ http://dryice.3322.org Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/sylvester-response.html -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 186 bytes Desc: not available Url : http://lists.exoweb.net/pipermail/python-chinese/attachments/20050717/e7d4eadf/attachment.pgp
2005年07月17日 星期日 14:10
如果每个FTP服务器都不一样,那怎么才能做出兼容的软件呢? On 7/17/05, Dryice Liu <dryiceliu at gmail.com> wrote: > > IIS 好象默认的是 msdos 格式 > 和传统的 unix 格式不一样 > > Leo Jay <python.leojay at gmail.com> wrote: > > > 没有。手上可以给我试的FTP就一个,所以…… > > 都会有哪些日期的可能呢? > > > > > > On 7/16/05, Jason Liu <telecomliu at gmail.com> wrote: > >> 不同的FTP server返回的格式是不同的,您考虑过没有? > >> > >> 在 05-7-16,Leo Jay<python.leojay at gmail.com> 写道: > >> > 谢谢大家的帮忙,我自己写了解析的部分, > >> > 把我的代码片断分享给大家,希望有用: > >> > > >> > fileLinePattern = re.compile( > >> > r'^(?P.)(?P > >> > r'(?P.{9})\s+(?P \d*)\s*' \S+)\s+(?P > >> > r'(?P\S+)\s+(?P \d+)\s+' ...\s+\d+\s+[\d:]+)\s+(?P > >> > r'( -> (?P([^ ]|\\ )*?)' [^\r]*))?\r?$' > >> > ) > >> > > >> > # 传入一行,返回一个字典,记录文件的信息 > >> > def parseDirectoryLine(line): > >> > match = fileLinePattern.match(line) > >> > if match is None: > >> > return None > >> > else: > >> > d = match.groupdict() > >> > d['filename'] = d['filename'].replace(r'\ ', ' ') > >> > d['nlinks'] = int(d['nlinks']) > >> > d['size'] = int(d['size']) > >> > > >> > if d['date'][-3] == ':': > >> > t = time.strptime(d['date'],'%b %d %H:%M') > >> > t = datetime.datetime(datetime.datetime.today().year, > >> > t[1], t[2], t[3], t[4] ) > >> > else: > >> > t = time.strptime(d['date'],'%b %d %Y') > >> > t = datetime.datetime(t[0],t[1],t[2]) > >> > > >> > d['date'] = t > >> > > >> > if d['linktarget']: > >> > d['linktarget'] = d['linktarget'].replace(r'\ ', ' ') > >> > > >> > files.append(d) > >> > return d > >> > > >> > On 7/16/05, Jason Liu <telecomliu at gmail.com> wrote: > >> > > 网上有一个解析FTP返回信息的C程序,我学习python时把它用python重新写了一遍。你看看合用不合用,里面应该有解析时间的能力。如果有错误也麻烦你指出来。 > >> > > > >> > > 程序在附件里。 > >> > > > >> > > 基本用法是 > >> > > ftpparse(info) ->ftpitem > >> > > info 是list返回的单个字符串。 > >> > > ftpitem是包含所有解析信息的list,内容与下面的C struct对应 > >> > > > >> > > struct ftpparse { > >> > > char *name; /* not necessarily 0-terminated */ > >> > > int flagtrycwd; /* 0 if cwd is definitely pointless, 1 otherwise */ > >> > > int flagtryretr; /* 0 if retr is definitely pointless, 1 otherwise */ > >> > > long size; /* number of octets */ > >> > > int mtimetype; > >> > > time_t mtime; /* modification time */ > >> > > int idtype; > >> > > char *id; /* not necessarily 0-terminated */ > >> > > } ; > >> > > > >> > > > >> > > >> > > >> > -- > >> > Best Regards, > >> > Leo Jay > >> > > >> > >> _______________________________________________ > >> python-chinese list > >> python-chinese at lists.python.cn > >> http://python.cn/mailman/listinfo/python-chinese > >> > >> > >> > > > > > > -- > > Best Regards, > > Leo Jay > > _______________________________________________ > > python-chinese list > > python-chinese at lists.python.cn > > http://python.cn/mailman/listinfo/python-chinese > > -- > Dryice @ http://dryice.3322.org > > Please avoid sending me Word or PowerPoint attachments. > See http://www.gnu.org/philosophy/sylvester-response.html > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > > > > -- Best Regards, Leo Jay
2005年07月17日 星期日 14:26
没什么好办法 我能想到的就是收集各种可能的格式然后一个一个的试 Leo Jay <python.leojay at gmail.com> wrote: > 如果每个FTP服务器都不一样,那怎么才能做出兼容的软件呢? > > On 7/17/05, Dryice Liu <dryiceliu at gmail.com> wrote: >> >> IIS 好象默认的是 msdos 格式 >> 和传统的 unix 格式不一样 >> >> Leo Jay <python.leojay at gmail.com> wrote: >> >> > 没有。手上可以给我试的FTP就一个,所以…… >> > 都会有哪些日期的可能呢? >> > >> > >> > On 7/16/05, Jason Liu <telecomliu at gmail.com> wrote: >> >> 不同的FTP server返回的格式是不同的,您考虑过没有? >> >> >> >> 在 05-7-16,Leo Jay<python.leojay at gmail.com> 写道: >> >> > 谢谢大家的帮忙,我自己写了解析的部分, >> >> > 把我的代码片断分享给大家,希望有用: >> >> > >> >> > fileLinePattern = re.compile( >> >> > r'^(?P.)(?P >> >> > r'(?P.{9})\s+(?P \d*)\s*' \S+)\s+(?P >> >> > r'(?P\S+)\s+(?P \d+)\s+' ...\s+\d+\s+[\d:]+)\s+(?P >> >> > r'( -> (?P([^ ]|\\ )*?)' [^\r]*))?\r?$' >> >> > ) >> >> > >> >> > # 传入一行,返回一个字典,记录文件的信息 >> >> > def parseDirectoryLine(line): >> >> > match = fileLinePattern.match(line) >> >> > if match is None: >> >> > return None >> >> > else: >> >> > d = match.groupdict() >> >> > d['filename'] = d['filename'].replace(r'\ ', ' ') >> >> > d['nlinks'] = int(d['nlinks']) >> >> > d['size'] = int(d['size']) >> >> > >> >> > if d['date'][-3] == ':': >> >> > t = time.strptime(d['date'],'%b %d %H:%M') >> >> > t = datetime.datetime(datetime.datetime.today().year, >> >> > t[1], t[2], t[3], t[4] ) >> >> > else: >> >> > t = time.strptime(d['date'],'%b %d %Y') >> >> > t = datetime.datetime(t[0],t[1],t[2]) >> >> > >> >> > d['date'] = t >> >> > >> >> > if d['linktarget']: >> >> > d['linktarget'] = d['linktarget'].replace(r'\ ', ' ') >> >> > >> >> > files.append(d) >> >> > return d >> >> > >> >> > On 7/16/05, Jason Liu <telecomliu at gmail.com> wrote: >> >> > > 网上有一个解析FTP返回信息的C程序,我学习python时把它用python重新写了一遍。你看看合用不合用,里面应该有解析时间的能力。如果有错误也麻烦你指出来。 >> >> > > >> >> > > 程序在附件里。 >> >> > > >> >> > > 基本用法是 >> >> > > ftpparse(info) ->ftpitem >> >> > > info 是list返回的单个字符串。 >> >> > > ftpitem是包含所有解析信息的list,内容与下面的C struct对应 >> >> > > >> >> > > struct ftpparse { >> >> > > char *name; /* not necessarily 0-terminated */ >> >> > > int flagtrycwd; /* 0 if cwd is definitely pointless, 1 otherwise */ >> >> > > int flagtryretr; /* 0 if retr is definitely pointless, 1 otherwise */ >> >> > > long size; /* number of octets */ >> >> > > int mtimetype; >> >> > > time_t mtime; /* modification time */ >> >> > > int idtype; >> >> > > char *id; /* not necessarily 0-terminated */ >> >> > > } ; >> >> > > >> >> > > >> >> > >> >> > >> >> > -- >> >> > Best Regards, >> >> > Leo Jay >> >> > >> >> >> >> _______________________________________________ >> >> python-chinese list >> >> python-chinese at lists.python.cn >> >> http://python.cn/mailman/listinfo/python-chinese >> >> >> >> >> >> >> > >> > >> > -- >> > Best Regards, >> > Leo Jay >> > _______________________________________________ >> > python-chinese list >> > python-chinese at lists.python.cn >> > http://python.cn/mailman/listinfo/python-chinese >> >> -- >> Dryice @ http://dryice.3322.org >> >> Please avoid sending me Word or PowerPoint attachments. >> See http://www.gnu.org/philosophy/sylvester-response.html >> >> _______________________________________________ >> python-chinese list >> python-chinese at lists.python.cn >> http://python.cn/mailman/listinfo/python-chinese >> >> >> >> > > > -- > Best Regards, > Leo Jay > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese -- Dryice @ http://dryice.3322.org Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/sylvester-response.html -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 186 bytes Desc: not available Url : http://lists.exoweb.net/pipermail/python-chinese/attachments/20050717/1663a44c/attachment.pgp
2005年07月17日 星期日 14:28
没什么好办法 我能想到的就是收集各种可能的格式然后一个一个的试 Leo Jay <python.leojay at gmail.com> wrote: > 如果每个FTP服务器都不一样,那怎么才能做出兼容的软件呢? > > On 7/17/05, Dryice Liu <dryiceliu at gmail.com> wrote: >> >> IIS 好象默认的是 msdos 格式 >> 和传统的 unix 格式不一样 >> >> Leo Jay <python.leojay at gmail.com> wrote: >> >> > 没有。手上可以给我试的FTP就一个,所以…… >> > 都会有哪些日期的可能呢? >> > >> > >> > On 7/16/05, Jason Liu <telecomliu at gmail.com> wrote: >> >> 不同的FTP server返回的格式是不同的,您考虑过没有? >> >> >> >> 在 05-7-16,Leo Jay<python.leojay at gmail.com> 写道: >> >> > 谢谢大家的帮忙,我自己写了解析的部分, >> >> > 把我的代码片断分享给大家,希望有用: >> >> > >> >> > fileLinePattern = re.compile( >> >> > r'^(?P.)(?P >> >> > r'(?P.{9})\s+(?P \d*)\s*' \S+)\s+(?P >> >> > r'(?P\S+)\s+(?P \d+)\s+' ...\s+\d+\s+[\d:]+)\s+(?P >> >> > r'( -> (?P([^ ]|\\ )*?)' [^\r]*))?\r?$' >> >> > ) >> >> > >> >> > # 传入一行,返回一个字典,记录文件的信息 >> >> > def parseDirectoryLine(line): >> >> > match = fileLinePattern.match(line) >> >> > if match is None: >> >> > return None >> >> > else: >> >> > d = match.groupdict() >> >> > d['filename'] = d['filename'].replace(r'\ ', ' ') >> >> > d['nlinks'] = int(d['nlinks']) >> >> > d['size'] = int(d['size']) >> >> > >> >> > if d['date'][-3] == ':': >> >> > t = time.strptime(d['date'],'%b %d %H:%M') >> >> > t = datetime.datetime(datetime.datetime.today().year, >> >> > t[1], t[2], t[3], t[4] ) >> >> > else: >> >> > t = time.strptime(d['date'],'%b %d %Y') >> >> > t = datetime.datetime(t[0],t[1],t[2]) >> >> > >> >> > d['date'] = t >> >> > >> >> > if d['linktarget']: >> >> > d['linktarget'] = d['linktarget'].replace(r'\ ', ' ') >> >> > >> >> > files.append(d) >> >> > return d >> >> > >> >> > On 7/16/05, Jason Liu <telecomliu at gmail.com> wrote: >> >> > > 网上有一个解析FTP返回信息的C程序,我学习python时把它用python重新写了一遍。你看看合用不合用,里面应该有解析时间的能力。如果有错误也麻烦你指出来。 >> >> > > >> >> > > 程序在附件里。 >> >> > > >> >> > > 基本用法是 >> >> > > ftpparse(info) ->ftpitem >> >> > > info 是list返回的单个字符串。 >> >> > > ftpitem是包含所有解析信息的list,内容与下面的C struct对应 >> >> > > >> >> > > struct ftpparse { >> >> > > char *name; /* not necessarily 0-terminated */ >> >> > > int flagtrycwd; /* 0 if cwd is definitely pointless, 1 otherwise */ >> >> > > int flagtryretr; /* 0 if retr is definitely pointless, 1 otherwise */ >> >> > > long size; /* number of octets */ >> >> > > int mtimetype; >> >> > > time_t mtime; /* modification time */ >> >> > > int idtype; >> >> > > char *id; /* not necessarily 0-terminated */ >> >> > > } ; >> >> > > >> >> > > >> >> > >> >> > >> >> > -- >> >> > Best Regards, >> >> > Leo Jay >> >> > >> >> >> >> _______________________________________________ >> >> python-chinese list >> >> python-chinese at lists.python.cn >> >> http://python.cn/mailman/listinfo/python-chinese >> >> >> >> >> >> >> > >> > >> > -- >> > Best Regards, >> > Leo Jay >> > _______________________________________________ >> > python-chinese list >> > python-chinese at lists.python.cn >> > http://python.cn/mailman/listinfo/python-chinese >> >> -- >> Dryice @ http://dryice.3322.org >> >> Please avoid sending me Word or PowerPoint attachments. >> See http://www.gnu.org/philosophy/sylvester-response.html >> >> _______________________________________________ >> python-chinese list >> python-chinese at lists.python.cn >> http://python.cn/mailman/listinfo/python-chinese >> >> >> >> > > > -- > Best Regards, > Leo Jay > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese -- Dryice @ http://dryice.3322.org Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/sylvester-response.html -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 186 bytes Desc: not available Url : http://lists.exoweb.net/pipermail/python-chinese/attachments/20050717/ecaa287f/attachment.pgp
2005年07月17日 星期日 16:08
就像新版的wget加入了对HTTP0.9的支持一样。 软件这样做下去就没完没了了。干脆,不管他…… On 7/17/05, Dryice Liu <dryiceliu at gmail.com> wrote: > > 没什么好办法 > 我能想到的就是收集各种可能的格式然后一个一个的试 > > Leo Jay <python.leojay at gmail.com> wrote: > > > 如果每个FTP服务器都不一样,那怎么才能做出兼容的软件呢? > > > > On 7/17/05, Dryice Liu <dryiceliu at gmail.com> wrote: > >> > >> IIS 好象默认的是 msdos 格式 > >> 和传统的 unix 格式不一样 > >> > >> Leo Jay <python.leojay at gmail.com> wrote: > >> > >> > 没有。手上可以给我试的FTP就一个,所以…… > >> > 都会有哪些日期的可能呢? > >> > > >> > > >> > On 7/16/05, Jason Liu <telecomliu at gmail.com> wrote: > >> >> 不同的FTP server返回的格式是不同的,您考虑过没有? > >> >> > >> >> 在 05-7-16,Leo Jay<python.leojay at gmail.com> 写道: > >> >> > 谢谢大家的帮忙,我自己写了解析的部分, > >> >> > 把我的代码片断分享给大家,希望有用: > >> >> > > >> >> > fileLinePattern = re.compile( > >> >> > r'^(?P.)(?P > >> >> > r'(?P.{9})\s+(?P \d*)\s*' \S+)\s+(?P > >> >> > r'(?P\S+)\s+(?P \d+)\s+' ...\s+\d+\s+[\d:]+)\s+(?P > >> >> > r'( -> (?P([^ ]|\\ )*?)' [^\r]*))?\r?$' > >> >> > ) > >> >> > > >> >> > # 传入一行,返回一个字典,记录文件的信息 > >> >> > def parseDirectoryLine(line): > >> >> > match = fileLinePattern.match(line) > >> >> > if match is None: > >> >> > return None > >> >> > else: > >> >> > d = match.groupdict() > >> >> > d['filename'] = d['filename'].replace(r'\ ', ' ') > >> >> > d['nlinks'] = int(d['nlinks']) > >> >> > d['size'] = int(d['size']) > >> >> > > >> >> > if d['date'][-3] == ':': > >> >> > t = time.strptime(d['date'],'%b %d %H:%M') > >> >> > t = datetime.datetime(datetime.datetime.today().year, > >> >> > t[1], t[2], t[3], t[4] ) > >> >> > else: > >> >> > t = time.strptime(d['date'],'%b %d %Y') > >> >> > t = datetime.datetime(t[0],t[1],t[2]) > >> >> > > >> >> > d['date'] = t > >> >> > > >> >> > if d['linktarget']: > >> >> > d['linktarget'] = d['linktarget'].replace(r'\ ', ' ') > >> >> > > >> >> > files.append(d) > >> >> > return d > >> >> > > >> >> > On 7/16/05, Jason Liu <telecomliu at gmail.com> wrote: > >> >> > > 网上有一个解析FTP返回信息的C程序,我学习python时把它用python重新写了一遍。你看看合用不合用,里面应该有解析时间的能力。如果有错误也麻烦你指出来。 > >> >> > > > >> >> > > 程序在附件里。 > >> >> > > > >> >> > > 基本用法是 > >> >> > > ftpparse(info) ->ftpitem > >> >> > > info 是list返回的单个字符串。 > >> >> > > ftpitem是包含所有解析信息的list,内容与下面的C struct对应 > >> >> > > > >> >> > > struct ftpparse { > >> >> > > char *name; /* not necessarily 0-terminated */ > >> >> > > int flagtrycwd; /* 0 if cwd is definitely pointless, 1 otherwise */ > >> >> > > int flagtryretr; /* 0 if retr is definitely pointless, 1 otherwise */ > >> >> > > long size; /* number of octets */ > >> >> > > int mtimetype; > >> >> > > time_t mtime; /* modification time */ > >> >> > > int idtype; > >> >> > > char *id; /* not necessarily 0-terminated */ > >> >> > > } ; > >> >> > > > >> >> > > > >> >> > > >> >> > > >> >> > -- > >> >> > Best Regards, > >> >> > Leo Jay > >> >> > > >> >> > >> >> _______________________________________________ > >> >> python-chinese list > >> >> python-chinese at lists.python.cn > >> >> http://python.cn/mailman/listinfo/python-chinese > >> >> > >> >> > >> >> > >> > > >> > > >> > -- > >> > Best Regards, > >> > Leo Jay > >> > _______________________________________________ > >> > python-chinese list > >> > python-chinese at lists.python.cn > >> > http://python.cn/mailman/listinfo/python-chinese > >> > >> -- > >> Dryice @ http://dryice.3322.org > >> > >> Please avoid sending me Word or PowerPoint attachments. > >> See http://www.gnu.org/philosophy/sylvester-response.html > >> > >> _______________________________________________ > >> python-chinese list > >> python-chinese at lists.python.cn > >> http://python.cn/mailman/listinfo/python-chinese > >> > >> > >> > >> > > > > > > -- > > Best Regards, > > Leo Jay > > _______________________________________________ > > python-chinese list > > python-chinese at lists.python.cn > > http://python.cn/mailman/listinfo/python-chinese > > -- > Dryice @ http://dryice.3322.org > > Please avoid sending me Word or PowerPoint attachments. > See http://www.gnu.org/philosophy/sylvester-response.html > > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > > > > -- Best Regards, Leo Jay
2005年07月17日 星期日 18:21
发现wget可以处理FTP上文件的日期,谁能不能帮忙试试wget支持的日期格式有哪些呢?IIS之类的应该没问题吧? On 7/17/05, Leo Jay <python.leojay at gmail.com> wrote: > 就像新版的wget加入了对HTTP0.9的支持一样。 > 软件这样做下去就没完没了了。干脆,不管他…… > > On 7/17/05, Dryice Liu <dryiceliu at gmail.com> wrote: > > > > 没什么好办法 > > 我能想到的就是收集各种可能的格式然后一个一个的试 > > > > Leo Jay <python.leojay at gmail.com> wrote: > > > > > 如果每个FTP服务器都不一样,那怎么才能做出兼容的软件呢? > > > > > > On 7/17/05, Dryice Liu <dryiceliu at gmail.com> wrote: > > >> > > >> IIS 好象默认的是 msdos 格式 > > >> 和传统的 unix 格式不一样 > > >> > > >> Leo Jay <python.leojay at gmail.com> wrote: > > >> > > >> > 没有。手上可以给我试的FTP就一个,所以…… > > >> > 都会有哪些日期的可能呢? > > >> > > > >> > > > >> > On 7/16/05, Jason Liu <telecomliu at gmail.com> wrote: > > >> >> 不同的FTP server返回的格式是不同的,您考虑过没有? > > >> >> > > >> >> 在 05-7-16,Leo Jay<python.leojay at gmail.com> 写道: > > >> >> > 谢谢大家的帮忙,我自己写了解析的部分, > > >> >> > 把我的代码片断分享给大家,希望有用: > > >> >> > > > >> >> > fileLinePattern = re.compile( > > >> >> > r'^(?P.)(?P > > >> >> > r'(?P.{9})\s+(?P \d*)\s*' \S+)\s+(?P > > >> >> > r'(?P\S+)\s+(?P \d+)\s+' ...\s+\d+\s+[\d:]+)\s+(?P > > >> >> > r'( -> (?P([^ ]|\\ )*?)' [^\r]*))?\r?$' > > >> >> > ) > > >> >> > > > >> >> > # 传入一行,返回一个字典,记录文件的信息 > > >> >> > def parseDirectoryLine(line): > > >> >> > match = fileLinePattern.match(line) > > >> >> > if match is None: > > >> >> > return None > > >> >> > else: > > >> >> > d = match.groupdict() > > >> >> > d['filename'] = d['filename'].replace(r'\ ', ' ') > > >> >> > d['nlinks'] = int(d['nlinks']) > > >> >> > d['size'] = int(d['size']) > > >> >> > > > >> >> > if d['date'][-3] == ':': > > >> >> > t = time.strptime(d['date'],'%b %d %H:%M') > > >> >> > t = datetime.datetime(datetime.datetime.today().year, > > >> >> > t[1], t[2], t[3], t[4] ) > > >> >> > else: > > >> >> > t = time.strptime(d['date'],'%b %d %Y') > > >> >> > t = datetime.datetime(t[0],t[1],t[2]) > > >> >> > > > >> >> > d['date'] = t > > >> >> > > > >> >> > if d['linktarget']: > > >> >> > d['linktarget'] = d['linktarget'].replace(r'\ ', ' ') > > >> >> > > > >> >> > files.append(d) > > >> >> > return d > > >> >> > > > >> >> > On 7/16/05, Jason Liu <telecomliu at gmail.com> wrote: > > >> >> > > 网上有一个解析FTP返回信息的C程序,我学习python时把它用python重新写了一遍。你看看合用不合用,里面应该有解析时间的能力。如果有错误也麻烦你指出来。 > > >> >> > > > > >> >> > > 程序在附件里。 > > >> >> > > > > >> >> > > 基本用法是 > > >> >> > > ftpparse(info) ->ftpitem > > >> >> > > info 是list返回的单个字符串。 > > >> >> > > ftpitem是包含所有解析信息的list,内容与下面的C struct对应 > > >> >> > > > > >> >> > > struct ftpparse { > > >> >> > > char *name; /* not necessarily 0-terminated */ > > >> >> > > int flagtrycwd; /* 0 if cwd is definitely pointless, 1 otherwise */ > > >> >> > > int flagtryretr; /* 0 if retr is definitely pointless, 1 otherwise */ > > >> >> > > long size; /* number of octets */ > > >> >> > > int mtimetype; > > >> >> > > time_t mtime; /* modification time */ > > >> >> > > int idtype; > > >> >> > > char *id; /* not necessarily 0-terminated */ > > >> >> > > } ; > > >> >> > > > > >> >> > > > > >> >> > > > >> >> > > > >> >> > -- > > >> >> > Best Regards, > > >> >> > Leo Jay > > >> >> > > > >> >> > > >> >> _______________________________________________ > > >> >> python-chinese list > > >> >> python-chinese at lists.python.cn > > >> >> http://python.cn/mailman/listinfo/python-chinese > > >> >> > > >> >> > > >> >> > > >> > > > >> > > > >> > -- > > >> > Best Regards, > > >> > Leo Jay > > >> > _______________________________________________ > > >> > python-chinese list > > >> > python-chinese at lists.python.cn > > >> > http://python.cn/mailman/listinfo/python-chinese > > >> > > >> -- > > >> Dryice @ http://dryice.3322.org > > >> > > >> Please avoid sending me Word or PowerPoint attachments. > > >> See http://www.gnu.org/philosophy/sylvester-response.html > > >> > > >> _______________________________________________ > > >> python-chinese list > > >> python-chinese at lists.python.cn > > >> http://python.cn/mailman/listinfo/python-chinese > > >> > > >> > > >> > > >> > > > > > > > > > -- > > > Best Regards, > > > Leo Jay > > > _______________________________________________ > > > python-chinese list > > > python-chinese at lists.python.cn > > > http://python.cn/mailman/listinfo/python-chinese > > > > -- > > Dryice @ http://dryice.3322.org > > > > Please avoid sending me Word or PowerPoint attachments. > > See http://www.gnu.org/philosophy/sylvester-response.html > > > > _______________________________________________ > > python-chinese list > > python-chinese at lists.python.cn > > http://python.cn/mailman/listinfo/python-chinese > > > > > > > > > > > -- > Best Regards, > Leo Jay > -- Best Regards, Leo Jay
Zeuux © 2025
京ICP备05028076号