From cfe7091222d6ce7e3a60fa8e8a9509d48f42478b Mon Sep 17 00:00:00 2001 From: Sascha Spreitzer Date: Wed, 3 Jun 2015 13:17:38 +0200 Subject: [PATCH] Fix docstrings for documentation --- README.md | 1 + src/sid/__init__.py | 22 ++++------------------ src/sid/lib.py | 38 +++++++++++++++++--------------------- 3 files changed, 22 insertions(+), 39 deletions(-) diff --git a/README.md b/README.md index d2cbf49..5abd82f 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ Python library to convert Windows SIDs ## Changelog * 0.1 + * Fix docstrings for documentation * Add setup.py * Add ldap filter feature * Fix sponsor links diff --git a/src/sid/__init__.py b/src/sid/__init__.py index ca3531b..7107845 100644 --- a/src/sid/__init__.py +++ b/src/sid/__init__.py @@ -1,25 +1,11 @@ ''' -The MIT License (MIT) +A Python module to convert Windows SIDs -Copyright (c) 2015 Sascha Spreitzer, Red Hat -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: +import sid -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +s = sid.sid('S-1-5-21-2127521184-1604012920-1887927527-72713') +print s.base64() ''' diff --git a/src/sid/lib.py b/src/sid/lib.py index c45bef6..1daca31 100644 --- a/src/sid/lib.py +++ b/src/sid/lib.py @@ -1,25 +1,5 @@ ''' -The MIT License (MIT) - -Copyright (c) 2015 Sascha Spreitzer, Red Hat - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +The lib contains exceptions, constants and the sid class ''' @@ -35,15 +15,28 @@ class sidException(Exception): + ''' + Base exception derived from Exception class + ''' pass class sidExceptionNoSuchType(sidException): + ''' + No such type exception. Used when class is not initialized properly. + ''' pass class sid(object): + ''' + Class to manage Windows SIDs + ''' def __init__(self, data, sidtype=SID_STRING): + ''' + Initialize class with either a string, binary or base64 sid. + For example, Anonymous user is string 'S-1-5-7' + ''' if sidtype == SID_STRING: self._sid = data return @@ -87,6 +80,9 @@ def __str__(self): return self._sid def __repr__(self): + ''' + Return representation of sid + ''' return repr( self._sid ) @classmethod