Skip to content

Commit 555bfcb

Browse files
Complete rename to fancyfetch
1 parent 0bf9ba8 commit 555bfcb

8 files changed

Lines changed: 81 additions & 82 deletions

File tree

src/configurationhandler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import constants as MeowfetchConstants
1+
import constants as FancyfetchConstants
22
import json5 as JSONFiveLibrary
33

44
def FetchConfiguration():
5-
with open(MeowfetchConstants.ConfigurationFile, 'r', encoding='UTF-8') as FilePointer:
5+
with open(FancyfetchConstants.ConfigurationFile, 'r', encoding='UTF-8') as FilePointer:
66
try:
77
return JSONFiveLibrary.load(FilePointer) # Return the configuration, parsed into a Python dictionary.
88
except Exception as e:

src/defaults/configuration.json5

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
// If you define the ascii here, you need to escape backslashes and single or double quotes by using a backslash before it.
3333
// Example: `\` should become `\\`, and `"` should become `\"`.
3434
"ascii":[
35-
"{{bold}}{{purple}}______ __ _ _ ",
36-
"{{bold}}{{purple}}| ___| / _| | | | | ",
37-
"{{bold}}{{purple}}| |_ __ _ _ __ ___ _ _| |_ ___| |_ ___| |__ ",
38-
"{{bold}}{{purple}}| _/ _` | '_ \\ / __| | | | _/ _ \\ __/ __| '_ \\ ",
39-
"{{bold}}{{purple}}| || (_| | | | | (__| |_| | || __/ || (__| | | |",
40-
"{{bold}}{{purple}}\\_| \\__,_|_| |_|\\___|\\__, |_| \\___|\\__\\___|_| |_|",
41-
"{{bold}}{{purple}} __/ | ",
42-
"{{bold}}{{purple}} |___/ "
35+
"<:bold:><:purple:>______ __ _ _ ",
36+
"<:bold:><:purple:>| ___| / _| | | | | ",
37+
"<:bold:><:purple:>| |_ __ _ _ __ ___ _ _| |_ ___| |_ ___| |__ ",
38+
"<:bold:><:purple:>| _/ _` | '_ \\ / __| | | | _/ _ \\ __/ __| '_ \\ ",
39+
"<:bold:><:purple:>| || (_| | | | | (__| |_| | || __/ || (__| | | |",
40+
"<:bold:><:purple:>\\_| \\__,_|_| |_|\\___|\\__, |_| \\___|\\__\\___|_| |_|",
41+
"<:bold:><:purple:> __/ | ",
42+
"<:bold:><:purple:> |___/ "
4343
],
4444
}

src/defaults/widgets/architecture.py

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/defaults/widgets/hostname.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ class Widget: # Must be named Widget.
22
def __init__(self):
33
# It is advised that you process your most intensive logic here.
44
import platform
5-
self.Value = "{{gold}}Hostname: {{white}}"+platform.node()
5+
self.Value = "<:gold:>Hostname: <:white:>"+platform.node()
66

77
def Get(self):return self.Value # Must be named Get, but may return anything that can be converted to a string.

src/defaults/widgets/os.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ class Widget: # Must be named Widget.
22
def __init__(self):
33
# It is advised that you process your most intensive logic here.
44
import platform
5-
self.Value = "{{gold}}OS: {{white}}"+platform.uname().system+" "+platform.uname().version
5+
#self.Value = "{{gold}}OS: {{white}}"+platform.uname().system+" "+platform.uname().version+" ("
6+
self.Value = f"<:gold:>OS: <:white:>{platform.uname().system} {platform.uname().version} ({platform.machine()})"
67

78
def Get(self):return self.Value # Must be named Get, but may return anything that can be converted to a string.

src/formatting.py

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
from rich.console import Console as RichConsole
33
from typing import Dict, Optional
44

5-
def RemoveDirectives(Text: str):return RegexLibrary.sub(r"\{\{.*?\}\}", "", Text)
5+
def RemoveDirectives(Text: str):
6+
return RegexLibrary.sub(r"<:.*?:>", "", Text)
67

78
def EnsureResetEnding(Line):
8-
if not Line.endswith("{{reset}}"):
9-
return Line + "{{reset}}"
10-
return Line
9+
if not Line.endswith("<:reset:>"):
10+
return Line + "<:reset:>"
11+
return Line
1112

12-
class MeowfetchColourFormatter:
13+
class FancyfetchColourFormatter:
1314
def __init__(self, CustomColours: Optional[Dict[str, str]] = None):
1415
self.Console = RichConsole(highlight=False)
1516

@@ -47,7 +48,7 @@ def __init__(self, CustomColours: Optional[Dict[str, str]] = None):
4748
if CustomColours:
4849
self.ColourMap.update(CustomColours)
4950

50-
self.TagPattern = RegexLibrary.compile(r"\{\{([^}]+)\}\}")
51+
self.TagPattern = RegexLibrary.compile(r"<:([^:]+):>")
5152

5253
def AddColour(self, Name: str, HexCode: str):
5354
self.ColourMap[Name.lower()] = HexCode
@@ -148,21 +149,24 @@ def GetAvailableStyles(self) -> Dict[str, str]:
148149
def FormatASCII(Lines, TargetLength:int|None=None):
149150
def ExtractVisibleText(Line):
150151
VisibleChars = []
151-
InDirective = False
152-
BraceCount = 0
152+
I = 0
153153

154-
for I, Char in enumerate(Line):
155-
if Char == "{" and I + 1 < len(Line) and Line[I + 1] == "{":
156-
InDirective = True
157-
BraceCount = 1
158-
elif Char == "{" and InDirective:
159-
BraceCount += 1
160-
elif Char == "}" and InDirective:
161-
BraceCount -= 1
162-
if BraceCount == 0:
163-
InDirective = False
164-
elif not InDirective:
165-
VisibleChars.append((Char, I))
154+
while I < len(Line):
155+
# Check for start of directive <:
156+
if I + 1 < len(Line) and Line[I:I+2] == "<:":
157+
# Find the end of directive :>
158+
EndPos = Line.find(":>", I + 2)
159+
if EndPos != -1:
160+
# Skip the entire directive including :>
161+
I = EndPos + 2
162+
else:
163+
# Malformed directive, treat as visible character
164+
VisibleChars.append((Line[I], I))
165+
I += 1
166+
else:
167+
# Regular visible character
168+
VisibleChars.append((Line[I], I))
169+
I += 1
166170

167171
return VisibleChars
168172

@@ -185,29 +189,30 @@ def TruncateToTarget(Line, TargetLen):
185189
CutoffPos = VisibleChars[TargetLen - 1][1] + 1
186190

187191
Result = []
188-
InDirective = False
189-
BraceCount = 0
192+
I = 0
190193

191-
for I, Char in enumerate(Line):
192-
if I >= CutoffPos and not InDirective:
193-
break
194-
195-
Result.append(Char)
196-
197-
if Char == "{" and I + 1 < len(Line) and Line[I + 1] == "{":
198-
InDirective = True
199-
BraceCount = 1
200-
elif Char == "{" and InDirective:
201-
BraceCount += 1
202-
elif Char == "}" and InDirective:
203-
BraceCount -= 1
204-
if BraceCount == 0:
205-
InDirective = False
194+
while I < len(Line):
195+
if I >= CutoffPos:
196+
# Check if we're in the middle of a directive
197+
if I + 1 < len(Line) and Line[I:I+2] == "<:":
198+
# Find the end of this directive and include it
199+
EndPos = Line.find(":>", I + 2)
200+
if EndPos != -1:
201+
# Include the complete directive
202+
Result.extend(Line[I:EndPos+2])
203+
I = EndPos + 2
204+
else:
205+
break
206+
else:
207+
break
208+
else:
209+
Result.append(Line[I])
210+
I += 1
206211

207212
ResultStr = "".join(Result)
208213

209-
if not ResultStr.endswith("{{reset}}"):
210-
ResultStr += "{{reset}}"
214+
if not ResultStr.endswith("<:reset:>"):
215+
ResultStr += "<:reset:>"
211216

212217
return ResultStr
213218

@@ -227,9 +232,9 @@ def TruncateToTarget(Line, TargetLen):
227232
for Line in ProcessedLines:
228233
VisibleLength = GetVisibleLength(Line)
229234
if VisibleLength < MaxVisibleLength:
230-
if Line.endswith("{{reset}}"):
235+
if Line.endswith("<:reset:>"):
231236
SpacesNeeded = MaxVisibleLength - VisibleLength
232-
AlignedLine = Line[:-9] + " " * SpacesNeeded + "{{reset}}"
237+
AlignedLine = Line[:-10] + " " * SpacesNeeded + "<:reset:>"
233238
else:
234239
SpacesNeeded = MaxVisibleLength - VisibleLength
235240
AlignedLine = Line + " " * SpacesNeeded

src/main.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import setup as MeowfetchSetup
2-
import constants as MeowfetchConstants
3-
import configurationhandler as MeowfetchConfigurationHandler
4-
import formatting as MeowfetchFormatting
5-
import widgets as MeowfetchWidgets
1+
import setup as FancyfetchSetup
2+
import constants as FancyfetchConstants
3+
import configurationhandler as FancyfetchConfigurationHandler
4+
import formatting as FancyfetchFormatting
5+
import widgets as FancyfetchWidgets
66

77
import shutil as ShellUtilityLibrary
88
import os as OperatingSystemLibrary
@@ -18,13 +18,13 @@ def CompareChildren(OriginalDirectory, Directory):
1818
Files = set(GetChildren(Directory))
1919
return OriginalFiles - Files
2020
def HasConfigurationBeenChanged():
21-
if (not MeowfetchConstants.WidgetsDirectory.exists()) or (not MeowfetchConstants.ConfigurationFile.exists()):
22-
MeowfetchSetup.EnsureConfiguration()
21+
if (not FancyfetchConstants.WidgetsDirectory.exists()) or (not FancyfetchConstants.ConfigurationFile.exists()):
22+
FancyfetchSetup.EnsureConfiguration()
2323
print("Your configuration has been regenerated!")
2424
exit(0)
25-
if len(CompareChildren(MeowfetchConstants.WidgetsDirectory, MeowfetchConstants.DefaultWidgetsDirectory)) > 0:
25+
if len(CompareChildren(FancyfetchConstants.WidgetsDirectory, FancyfetchConstants.DefaultWidgetsDirectory)) > 0:
2626
return True
27-
if open(MeowfetchConstants.ConfigurationFile, "r").read() != open(MeowfetchConstants.DefaultConfigurationFile, "r").read():
27+
if open(FancyfetchConstants.ConfigurationFile, "r").read() != open(FancyfetchConstants.DefaultConfigurationFile, "r").read():
2828
return True
2929

3030
def OPTION_RegenerateConfiguration():
@@ -36,16 +36,16 @@ def OPTION_RegenerateConfiguration():
3636
print("Type 'yes' to confirm, or anything else to cancel.")
3737
Confirmation = input().strip().lower()
3838
if Confirmation.lower().strip() in "yes":
39-
ShellUtilityLibrary.rmtree(MeowfetchConstants.ConfigurationDirectory, ignore_errors=True)
40-
MeowfetchSetup.EnsureConfiguration()
39+
ShellUtilityLibrary.rmtree(FancyfetchConstants.ConfigurationDirectory, ignore_errors=True)
40+
FancyfetchSetup.EnsureConfiguration()
4141
print("Your configuration has been regenerated!")
4242
exit(0)
4343
else:
4444
print("Configuration regeneration cancelled!")
4545
exit(0)
4646

4747
def OPTION_Configuration():
48-
MeowfetchSetup.EnsureConfiguration()
48+
FancyfetchSetup.EnsureConfiguration()
4949
print("Configuration files are accessible at '~/.config/fancyfetch/'!")
5050
exit(0)
5151

@@ -78,8 +78,8 @@ def Main():
7878
elif Args.regen:
7979
OPTION_RegenerateConfiguration()
8080

81-
MeowfetchSetup.EnsureConfiguration()
82-
Configuration = MeowfetchConfigurationHandler.FetchConfiguration()
81+
FancyfetchSetup.EnsureConfiguration()
82+
Configuration = FancyfetchConfigurationHandler.FetchConfiguration()
8383

8484
CONFIG_DisplayASCII = Configuration.get("display_ascii", True) # Default to True if not set.
8585
CONFIG_ASCIILocation = Configuration.get("ascii_location", "left") # Default to "left" if not set.
@@ -90,13 +90,13 @@ def Main():
9090

9191
ASCII = CONFIG_ASCII if CONFIG_DisplayASCII else []
9292
try:
93-
Layout = [MeowfetchWidgets.LoadWidget(str(MeowfetchConstants.WidgetsDirectory), X) for X in CONFIG_Layout]
93+
Layout = [FancyfetchWidgets.LoadWidget(str(FancyfetchConstants.WidgetsDirectory), X) for X in CONFIG_Layout]
9494
except ValueError as e:
9595
print(e.args[0])
9696
exit(1)
9797

98-
MeowfetchFormatting.MeowfetchColourFormatter(None).Print(
99-
MeowfetchFormatting.Formatter(
98+
FancyfetchFormatting.FancyfetchColourFormatter(None).Print(
99+
FancyfetchFormatting.Formatter(
100100
ASCII,
101101
Layout,
102102
ShellUtilityLibrary.get_terminal_size().columns,
@@ -110,5 +110,5 @@ def Main():
110110
try:
111111
Main()
112112
except KeyboardInterrupt:
113-
print("\nExiting Meowfetch...")
113+
print("\nExiting Fancyfetch...")
114114
exit(0)

src/setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import shutil as ShellUtilityLibrary
22
import os as OperatingSystemLibrary
33

4-
import constants as MeowfetchConstants
4+
import constants as FancyfetchConstants
55

66
# Functions
77
def EnsureConfigurationDirectory():
8-
MeowfetchConstants.ConfigurationDirectory.mkdir(exist_ok=True, parents=True)
8+
FancyfetchConstants.ConfigurationDirectory.mkdir(exist_ok=True, parents=True)
99

1010
def CopyDirectoryContents(SourceDirectory, DestinationDirectory):
1111
for Item in OperatingSystemLibrary.listdir(SourceDirectory):
@@ -19,7 +19,7 @@ def CopyDirectoryContents(SourceDirectory, DestinationDirectory):
1919
ShellUtilityLibrary.copy(SourceItem, DestinationItem)
2020

2121
def EnsureConfiguration():
22-
if not MeowfetchConstants.ConfigurationDirectory.exists():
22+
if not FancyfetchConstants.ConfigurationDirectory.exists():
2323
EnsureConfigurationDirectory()
24-
CopyDirectoryContents(MeowfetchConstants.DefaultConfiguationDirectory, MeowfetchConstants.ConfigurationDirectory)
24+
CopyDirectoryContents(FancyfetchConstants.DefaultConfiguationDirectory, FancyfetchConstants.ConfigurationDirectory)
2525

0 commit comments

Comments
 (0)