Skip to content

Instantly share code, notes, and snippets.

@ShekharReddy4
Last active September 13, 2017 11:48
Show Gist options
  • Save ShekharReddy4/4d167c6f854eb2ad3855dbe5817d6e71 to your computer and use it in GitHub Desktop.
Save ShekharReddy4/4d167c6f854eb2ad3855dbe5817d6e71 to your computer and use it in GitHub Desktop.
Examples for Enum and xml parser while I am coding AMS
*.pyc
/.vscode
"""
SettingsEnum documenation
"""
from enum import Enum, unique
@unique
class SettingsEnum(Enum):
"""
SettingsEnum Enum class
"""
PreviousSWUpdate = 0
IsUserServiceActive = 1
UserServiceRunPeriod = 2
NotifySW = 3
NotifySWEmail = 4
SWEventsToCapture = 5
ServiceVersion = 6
ServiceInsUserName = 7
ServiceInsPassword = 8
SNAEventsToCapture = 9
ResetLocalDB = 10
LogPath = 11
PreviousAIUpdate = 100
print SettingsEnum.LogPath.name
print SettingsEnum.LogPath.value
print repr(SettingsEnum.LogPath)
<config>
<mysql>
<host>localhost</host>
<user>root</user>
<passwd>my secret password</passwd>
<db>write-math</db>
</mysql>
<other>
<preprocessing_queue>
<li>preprocessing.scale_and_center</li>
<li>preprocessing.dot_reduction</li>
<li>preprocessing.connect_lines</li>
<app>this is an app tag</app>
</preprocessing_queue>
<use_anonymous value="true" />
</other>
</config>
from Animal import SettingsEnum
# se= SettingsEnum()
print SettingsEnum.LogPath
"""
xml parser example
"""
from lxml import etree
with open("app.config") as f:
content = f.read()
y = etree.Element(content)
print(y.tag)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment