-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4364aef
commit 24a25ab
Showing
3 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
__version__ = "1.3.5" | ||
__version__ = "1.3.6" | ||
|
||
from vulners.api import Vulners |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
class AttributeList(list): | ||
""" | ||
A subclass of list that can accept additional attributes. | ||
Should be able to be used just like a regular list. | ||
The problem: | ||
a = [1, 2, 4, 8] | ||
a.x = "Hey!" # AttributeError: 'list' object has no attribute 'x' | ||
The solution: | ||
a = L(1, 2, 4, 8) | ||
a.x = "Hey!" | ||
print a # [1, 2, 4, 8] | ||
print a.x # "Hey!" | ||
print len(a) # 4 | ||
You can also do these: | ||
a = L( 1, 2, 4, 8 , x="Hey!" ) # [1, 2, 4, 8] | ||
a = L( 1, 2, 4, 8 )( x="Hey!" ) # [1, 2, 4, 8] | ||
a = L( [1, 2, 4, 8] , x="Hey!" ) # [1, 2, 4, 8] | ||
a = L( {1, 2, 4, 8} , x="Hey!" ) # [1, 2, 4, 8] | ||
a = L( [2 ** b for b in range(4)] , x="Hey!" ) # [1, 2, 4, 8] | ||
a = L( (2 ** b for b in range(4)) , x="Hey!" ) # [1, 2, 4, 8] | ||
a = L( 2 ** b for b in range(4) )( x="Hey!" ) # [1, 2, 4, 8] | ||
a = L( 2 ) # [2] | ||
""" | ||
def __new__(self, *args, **kwargs): | ||
return list.__new__(self, args, kwargs) | ||
|
||
def __init__(self, *args, **kwargs): | ||
if len(args) == 1 and hasattr(args[0], '__iter__'): | ||
list.__init__(self, args[0]) | ||
else: | ||
list.__init__(self, args) | ||
self.__dict__.update(kwargs) | ||
|
||
def __call__(self, **kwargs): | ||
self.__dict__.update(kwargs) | ||
return self |