Comments (3)
Honestly, I don't longer remember the reasoning, and will have to go over it.
As for aligning it - I am concerned about backwards compatibility. what do you think?
from sark.
Is it possible (though it's horrible) to support both simultaneously somehow (and mark one way as deprecated)?
Any other solution would obv. break compatibility. This is life. Libraries evolve.
P.S. as you know, I have my fair share of scripts to update accordingly, I am not taking it lightly.
from sark.
In case you guys want this, I needed something pretty similar at one point and I wrote some pretty hacky-looking code that combines an iterator with a list. It adds a .reset()
method which will reset the iterator, but it forwards all list methods to the backend list, and implements all the methods implemented by the real listiterator
. This way it should act just like a regular python2 iterator despite it being stored internally as a list.
class listiterator(object):
def __init__(self, iterator=()):
self.__state__ = list(iterator)
self.reset()
def reset(self):
self.__sequence__ = iter(self.__state__)
return self
def next(self):
return next(self.__sequence__)
def __getattr__(self, name):
return getattr(self.__state__, name)
def __iter__(self):
return self.__sequence__
def __length_hint__(self):
return len(self.__state__)
# sneak out a method constructor
imcons = type(listiterator.__init__)
# call a method from an object using a closure to fetch it
methodcaller = lambda attribute: lambda self, *args, **kwargs: (lambda method=getattr(list, attribute): method(self.__state__, *args, **kwargs))()
# filter out all the descriptors that we need to copy from the `list` type
descriptors = (name for name in dir(list) if name not in listiterator.__dict__ and name not in object.__dict__)
descriptors = ((name, getattr(list, name)) for name in descriptors if name.startswith('__'))
descriptors = (name for name, value in descriptors if callable(value) and getattr(value, '__objclass__', None) == list)
# use methodcaller to construct an unbound method for the method descriptors we snagged
for name in descriptors:
setattr(listiterator, name, imcons(methodcaller(name), None, listiterator))
(edited to add comments)
from sark.
Related Issues (20)
- AttributeError: 'module' object has no attribute 'FF_DWRD' HOT 1
- Deprecated symbols in IDA Python HOT 1
- segfault ida64 on Mac HOT 2
- Fix ReadTheDocs build
- Potential incorrect parsing of x64 phrases HOT 3
- networkx updated
- Trying to create a codeblock with a bad address resulnts in non-descriptive exception HOT 1
- Create binaries to use for test suite HOT 1
- Create sark-based data-dumpers HOT 1
- Evaluate test frameworks HOT 1
- discrepancy between sark.Line(ea=foo).is_tail and is_tail(idc.GetFlags(ea)), also for is_code HOT 9
- Support running via "idat"
- add explanation about switching to python3
- Highlight calls plugin broken HOT 2
- Unable to attach IDA Pro to Visual Studio HOT 5
- MIssing size for tbyte operand in DTYPE_TO_SIZE HOT 4
- IDA 7.0 cannot import Sark when running python script HOT 3
- Does Sark cover accessing strings or other constant symbols? HOT 2
- "Expected an ea_t type" when calling `sark.Segment("__TEXT")` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sark.