Last active
September 13, 2017 11:48
-
-
Save ShekharReddy4/4d167c6f854eb2ad3855dbe5817d6e71 to your computer and use it in GitHub Desktop.
Examples for Enum and xml parser while I am coding AMS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
*.pyc | |
/.vscode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from Animal import SettingsEnum | |
# se= SettingsEnum() | |
print SettingsEnum.LogPath |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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