2 # Copyright (C) 2006 Google Inc.
3 # Copyright (C) 2008 David Euresti
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
19 from xml
.etree
import cElementTree
as ElementTree
22 import cElementTree
as ElementTree
24 from elementtree
import ElementTree
29 GFIN_NAMESPACE
= 'http://schemas.google.com/finance/2007'
31 class PortfolioListEntry(gdata
.GDataEntry
):
33 _namespace
= atom
.ATOM_NAMESPACE
34 _children
= gdata
.GDataEntry
._children
.copy()
35 _attributes
= gdata
.GDataEntry
._attributes
.copy()
38 def PortfolioListEntryFromString(xml_string
):
39 """Converts an XML string into a PortfolioListEntry object.
42 xml_string: string The XML describing a Document List feed entry.
45 A DocumentListEntry object corresponding to the given XML.
47 return atom
.CreateClassFromXMLString(PortfolioListEntry
,
50 class PortfolioListFeed(gdata
.GDataFeed
):
51 """A feed containing a list of Portfolio Items"""
54 _namespace
= atom
.ATOM_NAMESPACE
55 _children
= gdata
.GDataFeed
._children
.copy()
56 _attributes
= gdata
.GDataFeed
._attributes
.copy()
57 _children
['{%s}entry' % atom
.ATOM_NAMESPACE
] = ('entry',
60 def PortfolioListFeedFromString(xml_string
):
61 """Converts an XML string into a PortfolioListFeed object.
64 xml_string: string The XML describing a PortfolioList feed.
67 A PortfolioListFeed object corresponding to the given XML.
69 return atom
.CreateClassFromXMLString(PortfolioListFeed
, xml_string
)
72 class Symbol(atom
.AtomBase
):
75 _namespace
= GFIN_NAMESPACE
76 _children
= atom
.AtomBase
._children
.copy()
77 _attributes
= atom
.AtomBase
._attributes
.copy()
78 _attributes
['symbol'] = 'symbol'
79 _attributes
['fullName'] = 'fullName'
81 def __init__(self
, extension_elements
=None, value
=None, scope_type
=None,
82 extension_attributes
=None, text
=None):
84 self
.type = scope_type
86 self
.extension_elements
= extension_elements
or []
87 self
.extension_attributes
= extension_attributes
or {}
89 class PositionData(atom
.AtomBase
):
92 _namespace
= GFIN_NAMESPACE
93 _children
= atom
.AtomBase
._children
.copy()
94 _attributes
= atom
.AtomBase
._attributes
.copy()
95 _attributes
['shares'] = 'shares'
97 def __init__(self
, extension_elements
=None, value
=None, scope_type
=None,
98 extension_attributes
=None, text
=None):
100 self
.type = scope_type
102 self
.extension_elements
= extension_elements
or []
103 self
.extension_attributes
= extension_attributes
or {}
106 class PositionListEntry(gdata
.GDataEntry
):
108 _namespace
= atom
.ATOM_NAMESPACE
109 _children
= gdata
.GDataEntry
._children
.copy()
110 _attributes
= gdata
.GDataEntry
._attributes
.copy()
112 _children
['{%s}symbol' % GFIN_NAMESPACE
] = ('symbol', Symbol
)
113 _children
['{%s}positionData' % GFIN_NAMESPACE
] = ('positionData',
117 def PositionListEntryFromString(xml_string
):
118 """Converts an XML string into a PositionListEntry object.
121 xml_string: string The XML describing a Position List feed entry.
124 A PositionListEntry object corresponding to the given XML.
126 return atom
.CreateClassFromXMLString(PositionListEntry
, xml_string
)
130 class PositionListFeed(gdata
.GDataFeed
):
131 """A feed containing a list of Position Items"""
134 _namespace
= atom
.ATOM_NAMESPACE
135 _children
= gdata
.GDataFeed
._children
.copy()
136 _attributes
= gdata
.GDataFeed
._attributes
.copy()
137 _children
['{%s}entry' % atom
.ATOM_NAMESPACE
] = ('entry',
141 def PositionListFeedFromString(xml_string
):
142 """Converts an XML string into a PositionListFeed object.
145 xml_string: string The XML describing a PositionList feed.
148 A PositionListFeed object corresponding to the given XML.
150 return atom
.CreateClassFromXMLString(PositionListFeed
, xml_string
)