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
import pyrfc | |
class SapWrapper: | |
def __init__(self, connection: pyrfc.Connection): | |
self._connection = connection | |
def _read_table(self, table_name: str): | |
results = self._connection.call( | |
"RFC_READ_TABLE", | |
QUERY_TABLE=table_name, |
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
# The decorator to cache function calls | |
def cached(func): | |
cache = dict() | |
def decorator(*args): | |
if tuple(args) not in cache: | |
cache[tuple(args)] = func(*args) | |
return cache[tuple(args)] | |
return decorator | |
# Usage example |
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
def mark_multiples(ls, num, marker): | |
for i in range(num, len(ls), num): | |
ls[i] = marker if isinstance(ls[i], int) else (ls[i] + marker) | |
def main(): | |
size = 100 | |
nums = list(range(size+1)) | |
mark_multiples(nums, 3, "Fizz") | |
mark_multiples(nums, 5, "Buzz") | |
[print(num) for num in nums[1:]] |
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
class Dto(type): | |
def __new__(self,name,bases,at_dict,attributes): | |
at_dict["_properties"] = attributes | |
def init(self,**kwargs): | |
for _property in attributes: | |
received_value = kwargs.get(_property.name) | |
if received_value is not None: | |
if isinstance(received_value,_property.type): |
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
import libarchive.public #Not Secure? | |
# Reading the archived 7z file as bytes | |
with open('csvarchive.7z','rb') as f: | |
archive_bytes = f.read() | |
# The function that you might want to use | |
def archive_bytes_to_file_bytes(archive_bytes): | |
global entry_var | |
with libarchive.public.memory_reader(archive_bytes) as reader: |
NewerOlder