From b3c389e6662b4320d686a07f66499165f1752440 Mon Sep 17 00:00:00 2001 From: despiegk Date: Wed, 20 Aug 2025 05:06:05 +0200 Subject: [PATCH] ... --- herolib.egg-info/PKG-INFO | 6 +- .../logger/__pycache__/search.cpython-313.pyc | Bin 7231 -> 5691 bytes herolib/core/logger/search.py | 67 ++++++++---------- .../__pycache__/ourtime.cpython-313.pyc | Bin 6114 -> 6123 bytes herolib/data/ourtime/ourtime.py | 1 + 5 files changed, 34 insertions(+), 40 deletions(-) diff --git a/herolib.egg-info/PKG-INFO b/herolib.egg-info/PKG-INFO index 4c640c5..3df5a00 100644 --- a/herolib.egg-info/PKG-INFO +++ b/herolib.egg-info/PKG-INFO @@ -14,7 +14,7 @@ has some usefull stuff as well ## Installation -You can install `herolib` directly from the Git repository using `uv pip` (or `pip`): +You can install `herolib` directly from the Git repository using `uv pip`: ```bash uv pip install git+https://git.ourworld.tf/herocode/herolib_python.git @@ -36,6 +36,10 @@ import herolib.core.loghandler.mylogging from herolib.core.loghandler.mylogging import MyLogger ``` +## how to integrate python in other projects + +see [Python Herolib Integration](pythonsetup/README.md) + ## Version Control This library follows standard Git version control practices. Releases can be managed by tagging specific commits in the Git repository. Users installing directly from the Git URL can specify a particular branch, tag, or commit hash to get a specific version. For example: diff --git a/herolib/core/logger/__pycache__/search.cpython-313.pyc b/herolib/core/logger/__pycache__/search.cpython-313.pyc index 5ae3dfa469fad532b4bd48aca736405d5bbfa70d..a38d087e720011a13f0a6b74af71bb155503c4fb 100644 GIT binary patch delta 2604 zcmZ`*eN0=|6+id+`TGOx_iTs_*a3&wgb>0-X;xLQ zaiWD%Lw~JWAWquJw>M_B029^;+k`M7PS{@snIx>^gaI*%S|c3Y&^Vn@>-@fQTwUHg z*rxY*4;Qu4Pk0ZHE;@QzBhahrIz5q82>~@G`VZcvtuJ|)_I6zki9d-*BemmI6+lVd zO{h!V*p;wHg{VF7Lx7kSU>uVylcb3X7Lc@2y9GM=?!BDi)TUKa{!?_09hr0q~{^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23@skSUrEy=QyERo7wnb_4_&RoBCK~lJ@n!H|^ zC^KUdH?B^?O~Yk|x^yFx8B0%I7@r)wwo6pGNi-#td@}~WLG&cmdadu zDKm@~4Ejzqp^}0trLm^ECb6y){k=IV(hi<>h&0R7>=u3Oe&t3|2%Zyz7x>@>A((o- z`?1OZ+l?P81#RtSV-Wt;_;U6!W4_Zd)p5r^<^Ld(W2~a{IPW|zIy-r1r{Fxf&4ky@ zJ4`rdbKB9ke6U{(4)DPNAvh#74&`iBGs(M2-uA+BVl}yvTu+K; zhWIl>LMvib&z!$|e!;(GYum?3_%6d{bJZ>w`AQ9p_9<)bkk>rpTJS9e76WTuu|BX> zAJ{WjO#9%?*_K;BTwoV6i|*x1KWlze>B`w%VttUW4~q3K^7StY_2F%Me4~5E9?!WO zmefn?<Z*6#R%)Hy@pgE;nqkfydRZ`M_LY*(+3^m{vdXcE0DDZ~STF zee(nRC-!Mo&VF?Eh1uBj_e6UWZ*LOpo@qtySlvR)f_HX2JFWert7*-;;oVGJ5EEm3 zVoXR}*?jdi-gWaQ)bGn{?pkveRE#J^cKj~a^La?@P>qBb;qCO<(LsChpXR_+q z(0q6e)!}jG&mOGKD2ya4; zEkzb1Qr-6P{=S_C#HzRxor=yjh^FSxIUJN8*&oCKWqdvQk1xNC14G3Z0MnHHjxz1T zcTLB#c&Qte!8;Mu-HPm!X!)-R^aBF?s#2Q-_^;Kck}Uo}S(-GG56o&b-=vz7$B8{q zlGKxXG$!@Nl4O-;&#FM&y{dfAmL$F8UJEAm$LaGL)u(C<^|gkK^dRmkCvUzop1zVn zKUd(XvhQFg;O#Q6LxP9QQK>8ZhayR;{nxIK-ncq;DsvJ3sjRtX1jCGPUfu`NIDM`# QE`*lNi_yR5Y5A@H0m*Lsf&c&j diff --git a/herolib/core/logger/search.py b/herolib/core/logger/search.py index fe9b164..f45f85c 100644 --- a/herolib/core/logger/search.py +++ b/herolib/core/logger/search.py @@ -24,7 +24,7 @@ def search(l: Logger, args_: SearchArgs) -> List[LogItem]: raise ValueError('category cannot be longer than 10 chars') from_time = args.timestamp_from.unix() if args.timestamp_from else 0 - to_time = args.timestamp_to.unix() if args.timestamp_to else ourtime_new('2100-01-01').unix() + to_time = args.timestamp_to.unix() + 1 if args.timestamp_to else ourtime_new('2100-01-01').unix() if from_time > to_time: raise ValueError(f'from_time cannot be after to_time: {from_time} > {to_time}') @@ -62,52 +62,41 @@ def search(l: Logger, args_: SearchArgs) -> List[LogItem]: if len(result) >= args.maxitems: break - if not line.strip() and current_item: - if from_time <= current_item.timestamp.unix() <= to_time: - if (not args.cat or args.cat == current_item.cat) and \ - (not args.log or args.log.lower() in current_item.log.lower()) and \ - (args.logtype is None or args.logtype == current_item.logtype): - result.append(current_item) - current_item = None - continue - - if not line.startswith(' ') and not line.startswith('E'): + # Helper to add current_item to result if it matches criteria + def _add_item_if_matches(): + nonlocal current_item if current_item: if from_time <= current_item.timestamp.unix() <= to_time: - if (not args.cat or args.cat == current_item.cat) and \ - (not args.log or args.log.lower() in current_item.log.lower()) and \ - (args.logtype is None or args.logtype == current_item.logtype): - result.append(current_item) + if (not args.cat or args.cat == current_item.cat) and \ + (not args.log or args.log.lower() in current_item.log.lower()) and \ + (args.logtype is None or args.logtype == current_item.logtype): + result.append(current_item) + current_item = None # Reset after processing + + if not line.strip(): # Empty line, finalize previous item + _add_item_if_matches() + continue + + if not line.startswith(' ') and not line.startswith('E'): # New timestamp line + _add_item_if_matches() # Finalize previous item try: current_time = ourtime_new(f"{file_time.day()} {line.strip()}") - current_item = None except ValueError: current_time = None - current_item = None + current_item = None # Reset for new item elif current_time: - if line.startswith(' ') or line.startswith('E'): - if len(line) > 14 and line[13] == '-': - if current_item: - if from_time <= current_item.timestamp.unix() <= to_time: - if (not args.cat or args.cat == current_item.cat) and \ - (not args.log or args.log.lower() in current_item.log.lower()) and \ - (args.logtype is None or args.logtype == current_item.logtype): - result.append(current_item) - - is_error = line.startswith('E') - logtype = LogType.ERROR if is_error else LogType.STDOUT - cat = line[2:12].strip() - log_content = line[15:] + if len(line) > 14 and line[13] == '-': # New log entry line + _add_item_if_matches() # Finalize previous item + + is_error = line.startswith('E') + logtype = LogType.ERROR if is_error else LogType.STDOUT + cat = line[2:12].strip() + log_content = line[15:] - current_item = LogItem(timestamp=current_time, cat=cat, log=log_content.strip(), logtype=logtype) - elif current_item: - current_item.log += "\n" + (line[15:] if len(line) >15 else line) + current_item = LogItem(timestamp=current_time, cat=cat, log=log_content.strip(), logtype=logtype) + elif current_item: # Continuation line + current_item.log += "\n" + (line[15:] if len(line) >15 else line) - if current_item: - if from_time <= current_item.timestamp.unix() <= to_time: - if (not args.cat or args.cat == current_item.cat) and \ - (not args.log or args.log.lower() in current_item.log.lower()) and \ - (args.logtype is None or args.logtype == current_item.logtype): - result.append(current_item) + _add_item_if_matches() # Finalize the last item in the file return result \ No newline at end of file diff --git a/herolib/data/ourtime/__pycache__/ourtime.cpython-313.pyc b/herolib/data/ourtime/__pycache__/ourtime.cpython-313.pyc index 261231968f533778f0cdc1a7660a4f8ae1de21ff..3ef88e78b2e3a3ae046166fa7310c1621f362cb3 100644 GIT binary patch delta 341 zcmaE)|5~5-GcPX}0}v#eFU|P0kynU`F=ny?lPya|YEk~?Sf(s?#$TIHaQ4V^Mp>>R4G>QXNK|pFM(V2O>Z+zFsCpEc07WLB6mej*nam~XDgo9L1r)o*=~|JT zT2PXipQp)MlrlM8)QmA_@;p&#c5Z&Q2KUcWn-7TUGcx8*{vamLS^(5gJy}HD$Tk?r zDq;f>V3R~ZtQ-)b10q1`icnp7i^C>2KczG$)vl;;a20kynU`F=Da;lkMh2rYv^Gs?BFO|FH_&0p)M8796ic|iY!2c4Ty*YsS}NlFD^+e$xMzbGT+QE zq{%314pJuwBKSZ=5}4TRE1bb7!C9mM;z zxPO+|d{R`OkuhiTPceDce2_hpWyOtbgMh3eHV^?eUj)Pg8CIkNB0%bjP@R2?!zMRB xr8FniuBc#gkGPSp0;4121mzD5AbN)S7cl+7g^`ibXa-OeNG(wR3ZlS12LJ)WTloM0 diff --git a/herolib/data/ourtime/ourtime.py b/herolib/data/ourtime/ourtime.py index 8628359..9c55b6b 100644 --- a/herolib/data/ourtime/ourtime.py +++ b/herolib/data/ourtime/ourtime.py @@ -93,6 +93,7 @@ def new(time_str: str) -> OurTime: '%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M', '%Y-%m-%d %H', + '%Y-%m-%d-%H', # Add this format for dayhour parsing '%Y-%m-%d', '%d-%m-%Y %H:%M:%S', '%d-%m-%Y %H:%M',