Xorn
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Pages
doc
api
xorn
geda
fileformat.py
Go to the documentation of this file.
1
# xorn.geda - Python library for manipulating gEDA files
2
# Copyright (C) 1998-2010 Ales Hvezda
3
# Copyright (C) 1998-2010 gEDA Contributors (see ChangeLog for details)
4
# Copyright (C) 2013-2016 Roland Lutz
5
#
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software Foundation,
18
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20
## \namespace xorn.geda.fileformat
21
## File formats.
22
23
import
os.path
24
25
FORMAT_SCH, FORMAT_SYM, FORMAT_SCH_XML, FORMAT_SYM_XML = xrange(4)
26
27
VALID_FORMATS = {
28
'sch'
: FORMAT_SCH,
29
'sym'
: FORMAT_SYM,
30
'schxml'
: FORMAT_SCH_XML,
31
'symxml'
: FORMAT_SYM_XML
32
}
33
34
## Raised when the format of a file isn't specified and can't be
35
## guessed from the file name.
36
37
class
UnknownFormatError
(Exception):
38
pass
39
40
def
guess_format
(path):
41
basename = os.path.basename(path).lower()
42
if
basename.endswith(
'.sch'
):
43
return
FORMAT_SCH
44
if
basename.endswith(
'.sym'
):
45
return
FORMAT_SYM
46
if
basename.endswith(
'.sch.xml'
):
47
return
FORMAT_SCH_XML
48
if
basename.endswith(
'.sym.xml'
):
49
return
FORMAT_SYM_XML
50
raise
UnknownFormatError
xorn.geda.fileformat.guess_format
def guess_format
Definition:
fileformat.py:40
xorn.geda.fileformat.UnknownFormatError
Raised when the format of a file isn't specified and can't be guessed from the file name...
Definition:
fileformat.py:37
Generated on Sun Jul 17 2016 16:06:49 for Xorn by
1.8.8