[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/gnue-common/gnue/common __init__.py GConne...
From: |
Jason Cater |
Subject: |
gnue/gnue-common/gnue/common __init__.py GConne... |
Date: |
Wed, 06 Jun 2001 15:31:15 -0700 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Jason Cater <address@hidden> 01/06/06 15:31:15
Modified files:
gnue-common/gnue/common: __init__.py GConnections.py
Log message:
Added a convenience function, openResource, that handles opening a URL
or file resource
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/gnue/common/__init__.py.diff?cvsroot=OldCVS&tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue-common/gnue/common/GConnections.py.diff?cvsroot=OldCVS&tr1=1.7&tr2=1.8&r1=text&r2=text
Patches:
Index: gnue/gnue-common/gnue/common/GConnections.py
diff -u gnue/gnue-common/gnue/common/GConnections.py:1.7
gnue/gnue-common/gnue/common/GConnections.py:1.8
--- gnue/gnue-common/gnue/common/GConnections.py:1.7 Tue Jun 5 08:57:45 2001
+++ gnue/gnue-common/gnue/common/GConnections.py Wed Jun 6 15:31:15 2001
@@ -31,15 +31,12 @@
#
from GConfigParser import *
-import os
-import os.path
-import urllib
import string
import GDebug
import GDataObjects
import GLoginHandler
+from gnue.common import openResource
-
class NotFoundError (Error):
# Raised if a requested connection name does not
# exist in the Connections Definition File.
@@ -71,11 +68,8 @@
## self._parser = ConfigParser()
GDebug.printMesg(1,'Conn File: "%s"' % location)
- drive = os.path.splitdrive(location)
- if len(drive[0]):
- fileHandle = open(location,'r')
- else:
- fileHandle = urllib.urlopen(location)
+
+ fileHandle = openResource(location)
try:
self._parser.readfp(fileHandle)
@@ -232,7 +226,5 @@
except KeyError:
raise GDataObjects.ObjectTypeNotAvailableError, \
"DB Driver '%s' does not support source type '%s'" % (driver, type)
-
-
Index: gnue/gnue-common/gnue/common/__init__.py
diff -u gnue/gnue-common/gnue/common/__init__.py:1.2
gnue/gnue-common/gnue/common/__init__.py:1.3
--- gnue/gnue-common/gnue/common/__init__.py:1.2 Thu May 10 09:14:36 2001
+++ gnue/gnue-common/gnue/common/__init__.py Wed Jun 6 15:31:15 2001
@@ -1 +1,47 @@
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Copyright 2001 Free Software Foundation
+#
+# FILE:
+# gnue.common.__init__
+#
+# DESCRIPTION:
+#
+# NOTES:
+#
+# HISTORY:
+#
+
VERSION = '0.0.1'
+
+import os
+import urllib
+
+
+#
+# Open a file or URL resource,
+# properly handling drive letters.
+#
+def openResource(resource):
+ drive = os.path.splitdrive(resource)
+ if len(drive[0]):
+ return open(location,'r')
+ else:
+ return urllib.urlopen(resource)
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/gnue-common/gnue/common __init__.py GConne...,
Jason Cater <=