[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/common/src FileUtils.py gear/GearSystem.py...
From: |
Jan Ischebeck |
Subject: |
gnue/common/src FileUtils.py gear/GearSystem.py... |
Date: |
Wed, 18 Sep 2002 09:46:18 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Jan Ischebeck <address@hidden> 02/09/18 09:46:18
Modified files:
common/src : FileUtils.py
Added files:
common/src/gear: GearSystem.py NavigationBuilder.py
Log message:
finish .gear file access seperation
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/gear/GearSystem.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/gear/NavigationBuilder.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/FileUtils.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: gnue/common/src/FileUtils.py
diff -c gnue/common/src/FileUtils.py:1.1 gnue/common/src/FileUtils.py:1.2
*** gnue/common/src/FileUtils.py:1.1 Tue Sep 17 11:27:44 2002
--- gnue/common/src/FileUtils.py Wed Sep 18 09:46:18 2002
***************
*** 28,34 ****
#
import os, urllib, urlparse, sys
! import cStringIO, zipfile
############################################################
#
--- 28,34 ----
#
import os, urllib, urlparse, sys
! import cStringIO
############################################################
#
***************
*** 83,102 ****
if urltype!="gear":
return urllib.urlopen(resource)
- # load gear://archive/path/xxx.gfd
- # TODO: * add Zipfile write support. i.e. write stringbuffer into zipfile
- # if .. close is called
- # * provide zipfile cache, i.e. load zipfile just once into memory
-
else:
- #
- # TODO: Create a gear/GearSystem.py object that represents a
- # TODO: Gear "Filesystem". The, Move all of this logic
- # TODO: outside of openResource.
- #
-
- # urlparse sometimes didn't work correctly
if host=="":
# path="//host/path" -> path=path host=host
pathlist=string.split(path[2:],"/",1)
--- 83,92 ----
if urltype!="gear":
return urllib.urlopen(resource)
else:
+
+ from gnue.common.gear.GearSystem import GearFileSystem
if host=="":
# path="//host/path" -> path=path host=host
pathlist=string.split(path[2:],"/",1)
***************
*** 106,162 ****
# check if host ends in ".gear"
if host[-5:]!=".gear":
host=host+".gear"
!
# 1. search for gear in the local directory
try:
! zf=zipfile.ZipFile(host, mode="r")
except:
# 2. search in the package directory
if sys.platform=="win32":
host=sys.prefix+"/packages/"+host
else:
host=os.environ["HOME"]+"/gnue/packages/"+host
!
! zf=zipfile.ZipFile(host, mode="r")
if len(path):
! return cStringIO.StringIO(zf.read(path))
# if no path provided, create a navigator file for this archive
else:
- list=zf.namelist()
# check if the zip file contains a default navigator file
! if "default.gpd" in list:
! return cStringIO.StringIO(zf.read("default.gpd"))
! # convert a single filename to a full gear url
if resource[:5]!="gear:":
resource="gear://"+resource+"/"
! # reorder pathlist
! newlist={}
! for i in list:
! ps=string.split(i,"/",1)
! if ps[0]=="":
! ps[0]==ps[1]
! ps[1]=""
! if len(ps)==1 or ps[1]=="":
! newlist[ps[0]]=resource+i
! else:
! if not newlist.has_key(ps[0]):
! newlist[ps[0]]={}
!
! newlist[ps[0]][ps[1]]=resource+i
!
! if ps[1]=="README":
! buf=zf.read(i)
! buf=string.join(string.split(buf,"\n"),"<BR>\n")
! newlist[ps[0]][ps[1]]=buf
!
from gnue.common.gear.NavigationBuilder import buildNavigatorFile
- navi=buildNavigatorFile(newlist,host,1)
return cStringIO.StringIO(navi)
-
--- 96,135 ----
# check if host ends in ".gear"
if host[-5:]!=".gear":
host=host+".gear"
!
# 1. search for gear in the local directory
try:
! gear=GearFileSystem(host)
!
except:
# 2. search in the package directory
if sys.platform=="win32":
host=sys.prefix+"/packages/"+host
else:
host=os.environ["HOME"]+"/gnue/packages/"+host
!
! gear=GearFileSystem(host)
if len(path):
! return gear.openFile(path)
# if no path provided, create a navigator file for this archive
else:
# check if the zip file contains a default navigator file
! if gear.hasFile("default.gpd"):
! return gear.openFile("default.gpd")
!
! # convert a single filename to a full gear url
if resource[:5]!="gear:":
resource="gear://"+resource+"/"
! filelist = gear.getArchiveListing()
!
from gnue.common.gear.NavigationBuilder import buildNavigatorFile
+
+ navi=buildNavigatorFile(filelist,host,1)
return cStringIO.StringIO(navi)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/common/src FileUtils.py gear/GearSystem.py...,
Jan Ischebeck <=