-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheml.py
More file actions
39 lines (28 loc) · 761 Bytes
/
eml.py
File metadata and controls
39 lines (28 loc) · 761 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/env python
# -*- coding: utf-8 -*-
""":Mod: eml
:Synopsis:
Utilities for reading and parsing an Ecological Metadata Lanaguage XML file.
:Author:
servilla
:Created:
11/12/17
"""
import daiquiri
logger = daiquiri.getLogger(__name__)
from lxml import etree
class Eml(object):
def __init__(self, eml=None):
self.eml = eml
self.root = etree.fromstring(self.eml)
self._title = self._get_title()
def _get_title(self):
titles = self.root.xpath('//dataset/title')
for title in titles:
return title.text
@property
def title(self):
# Collapse to single line and spaces
title = ' '.join(self._title.split())
logger.info(title)
return title