~vauxoo/addons-vauxoo/8.0-import_tax_tariff-dev-yani-rev-2

« back to all changes in this revision

Viewing changes to openerp_print/pyPdf/xmp.py

  • Committer: Nhomar Hernandez
  • Date: 2013-04-19 20:33:12 UTC
  • mfrom: (542.1.314 addons-vauxoo)
  • Revision ID: nhomar@gmail.com-20130419203312-o35v7dn79l6vur0t
[MERGE - PEP8 AND V7-MIG] All migrated to V7 Just
improved osv.osv => osv.Model, osv.osv_memory => osv.TransientModel
import inside openerp.* enviroment
Erased class instansiation no necesarry anymore in V7
AUTOPEP8 run, Left PEP8 long lines manually.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
 
52
52
##
53
53
# An object that represents Adobe XMP metadata.
 
54
 
 
55
 
54
56
class XmpInformation(PdfObject):
55
57
 
56
58
    def __init__(self, stream):
103
105
        seconds = second.to_integral(decimal.ROUND_FLOOR)
104
106
        milliseconds = (second - seconds) * 1000000
105
107
        tzd = m.group("tzd") or "Z"
106
 
        dt = datetime.datetime(year, month, day, hour, minute, seconds, milliseconds)
 
108
        dt = datetime.datetime(
 
109
            year, month, day, hour, minute, seconds, milliseconds)
107
110
        if tzd != "Z":
108
111
            tzd_hours, tzd_minutes = [int(x) for x in tzd.split(":")]
109
112
            tzd_hours *= -1
198
201
    # Contributors to the resource (other than the authors).  An unsorted
199
202
    # array of names.
200
203
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
201
 
    dc_contributor = property(_getter_bag(DC_NAMESPACE, "contributor", _converter_string))
 
204
    dc_contributor = property(_getter_bag(
 
205
        DC_NAMESPACE, "contributor", _converter_string))
202
206
 
203
207
    ##
204
208
    # Text describing the extent or scope of the resource.
205
209
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
206
 
    dc_coverage = property(_getter_single(DC_NAMESPACE, "coverage", _converter_string))
 
210
    dc_coverage = property(_getter_single(
 
211
        DC_NAMESPACE, "coverage", _converter_string))
207
212
 
208
213
    ##
209
214
    # A sorted array of names of the authors of the resource, listed in order
210
215
    # of precedence.
211
216
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
212
 
    dc_creator = property(_getter_seq(DC_NAMESPACE, "creator", _converter_string))
 
217
    dc_creator = property(_getter_seq(
 
218
        DC_NAMESPACE, "creator", _converter_string))
213
219
 
214
220
    ##
215
221
    # A sorted array of dates (datetime.datetime instances) of signifigance to
221
227
    # A language-keyed dictionary of textual descriptions of the content of the
222
228
    # resource.
223
229
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
224
 
    dc_description = property(_getter_langalt(DC_NAMESPACE, "description", _converter_string))
 
230
    dc_description = property(_getter_langalt(
 
231
        DC_NAMESPACE, "description", _converter_string))
225
232
 
226
233
    ##
227
234
    # The mime-type of the resource.
228
235
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
229
 
    dc_format = property(_getter_single(DC_NAMESPACE, "format", _converter_string))
 
236
    dc_format = property(_getter_single(
 
237
        DC_NAMESPACE, "format", _converter_string))
230
238
 
231
239
    ##
232
240
    # Unique identifier of the resource.
233
241
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
234
 
    dc_identifier = property(_getter_single(DC_NAMESPACE, "identifier", _converter_string))
 
242
    dc_identifier = property(_getter_single(
 
243
        DC_NAMESPACE, "identifier", _converter_string))
235
244
 
236
245
    ##
237
246
    # An unordered array specifying the languages used in the resource.
238
247
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
239
 
    dc_language = property(_getter_bag(DC_NAMESPACE, "language", _converter_string))
 
248
    dc_language = property(_getter_bag(
 
249
        DC_NAMESPACE, "language", _converter_string))
240
250
 
241
251
    ##
242
252
    # An unordered array of publisher names.
243
253
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
244
 
    dc_publisher = property(_getter_bag(DC_NAMESPACE, "publisher", _converter_string))
 
254
    dc_publisher = property(_getter_bag(
 
255
        DC_NAMESPACE, "publisher", _converter_string))
245
256
 
246
257
    ##
247
258
    # An unordered array of text descriptions of relationships to other
248
259
    # documents.
249
260
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
250
 
    dc_relation = property(_getter_bag(DC_NAMESPACE, "relation", _converter_string))
 
261
    dc_relation = property(_getter_bag(
 
262
        DC_NAMESPACE, "relation", _converter_string))
251
263
 
252
264
    ##
253
265
    # A language-keyed dictionary of textual descriptions of the rights the
254
266
    # user has to this resource.
255
267
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
256
 
    dc_rights = property(_getter_langalt(DC_NAMESPACE, "rights", _converter_string))
 
268
    dc_rights = property(_getter_langalt(
 
269
        DC_NAMESPACE, "rights", _converter_string))
257
270
 
258
271
    ##
259
272
    # Unique identifier of the work from which this resource was derived.
260
273
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
261
 
    dc_source = property(_getter_single(DC_NAMESPACE, "source", _converter_string))
 
274
    dc_source = property(_getter_single(
 
275
        DC_NAMESPACE, "source", _converter_string))
262
276
 
263
277
    ##
264
278
    # An unordered array of descriptive phrases or keywrods that specify the
265
279
    # topic of the content of the resource.
266
280
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
267
 
    dc_subject = property(_getter_bag(DC_NAMESPACE, "subject", _converter_string))
 
281
    dc_subject = property(_getter_bag(
 
282
        DC_NAMESPACE, "subject", _converter_string))
268
283
 
269
284
    ##
270
285
    # A language-keyed dictionary of the title of the resource.
271
286
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
272
 
    dc_title = property(_getter_langalt(DC_NAMESPACE, "title", _converter_string))
 
287
    dc_title = property(_getter_langalt(
 
288
        DC_NAMESPACE, "title", _converter_string))
273
289
 
274
290
    ##
275
291
    # An unordered array of textual descriptions of the document type.
279
295
    ##
280
296
    # An unformatted text string representing document keywords.
281
297
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
282
 
    pdf_keywords = property(_getter_single(PDF_NAMESPACE, "Keywords", _converter_string))
 
298
    pdf_keywords = property(_getter_single(
 
299
        PDF_NAMESPACE, "Keywords", _converter_string))
283
300
 
284
301
    ##
285
302
    # The PDF file version, for example 1.0, 1.3.
286
303
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
287
 
    pdf_pdfversion = property(_getter_single(PDF_NAMESPACE, "PDFVersion", _converter_string))
 
304
    pdf_pdfversion = property(_getter_single(
 
305
        PDF_NAMESPACE, "PDFVersion", _converter_string))
288
306
 
289
307
    ##
290
308
    # The name of the tool that created the PDF document.
291
309
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
292
 
    pdf_producer = property(_getter_single(PDF_NAMESPACE, "Producer", _converter_string))
 
310
    pdf_producer = property(_getter_single(
 
311
        PDF_NAMESPACE, "Producer", _converter_string))
293
312
 
294
313
    ##
295
314
    # The date and time the resource was originally created.  The date and
296
315
    # time are returned as a UTC datetime.datetime object.
297
316
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
298
 
    xmp_createDate = property(_getter_single(XMP_NAMESPACE, "CreateDate", _converter_date))
299
 
    
 
317
    xmp_createDate = property(_getter_single(
 
318
        XMP_NAMESPACE, "CreateDate", _converter_date))
 
319
 
300
320
    ##
301
321
    # The date and time the resource was last modified.  The date and time
302
322
    # are returned as a UTC datetime.datetime object.
303
323
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
304
 
    xmp_modifyDate = property(_getter_single(XMP_NAMESPACE, "ModifyDate", _converter_date))
 
324
    xmp_modifyDate = property(_getter_single(
 
325
        XMP_NAMESPACE, "ModifyDate", _converter_date))
305
326
 
306
327
    ##
307
328
    # The date and time that any metadata for this resource was last
308
329
    # changed.  The date and time are returned as a UTC datetime.datetime
309
330
    # object.
310
331
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
311
 
    xmp_metadataDate = property(_getter_single(XMP_NAMESPACE, "MetadataDate", _converter_date))
 
332
    xmp_metadataDate = property(_getter_single(
 
333
        XMP_NAMESPACE, "MetadataDate", _converter_date))
312
334
 
313
335
    ##
314
336
    # The name of the first known tool used to create the resource.
315
337
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
316
 
    xmp_creatorTool = property(_getter_single(XMP_NAMESPACE, "CreatorTool", _converter_string))
 
338
    xmp_creatorTool = property(_getter_single(
 
339
        XMP_NAMESPACE, "CreatorTool", _converter_string))
317
340
 
318
341
    ##
319
342
    # The common identifier for all versions and renditions of this resource.
320
343
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
321
 
    xmpmm_documentId = property(_getter_single(XMPMM_NAMESPACE, "DocumentID", _converter_string))
 
344
    xmpmm_documentId = property(_getter_single(
 
345
        XMPMM_NAMESPACE, "DocumentID", _converter_string))
322
346
 
323
347
    ##
324
348
    # An identifier for a specific incarnation of a document, updated each
325
349
    # time a file is saved.
326
350
    # <p>Stability: Added in v1.12, will exist for all future v1.x releases.
327
 
    xmpmm_instanceId = property(_getter_single(XMPMM_NAMESPACE, "InstanceID", _converter_string))
 
351
    xmpmm_instanceId = property(_getter_single(
 
352
        XMPMM_NAMESPACE, "InstanceID", _converter_string))
328
353
 
329
354
    def custom_properties(self):
330
355
        if not hasattr(self, "_custom_properties"):
336
361
                    idx = key.find(u"\u2182")
337
362
                    if idx == -1:
338
363
                        break
339
 
                    key = key[:idx] + chr(int(key[idx+1:idx+5], base=16)) + key[idx+5:]
 
364
                    key = key[:idx] + chr(int(key[
 
365
                                          idx+1:idx+5], base=16)) + key[idx+5:]
340
366
                if node.nodeType == node.ATTRIBUTE_NODE:
341
367
                    value = node.nodeValue
342
368
                else:
351
377
    # @return Returns a dictionary of key/value items for custom metadata
352
378
    # properties.
353
379
    custom_properties = property(custom_properties)
354
 
 
355