nowtyping 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,24 @@
1
+ Metadata-Version: 2.4
2
+ Name: nowtyping
3
+ Version: 0.1.0
4
+ Summary: Create an offline introduction card to share with a person or their agent.
5
+ Author: NowTyping
6
+ Project-URL: Homepage, https://nowtyping.com/
7
+ Requires-Python: >=3.9
8
+ Description-Content-Type: text/markdown
9
+
10
+ # NowTyping
11
+
12
+ Create an introduction card for someone you would like to meet. The card records your name, who you are looking for, and optionally what you can offer and how to reach you.
13
+
14
+ ```sh
15
+ python -m pip install nowtyping
16
+ nowtyping --name "Noor" --looking-for "Python developers" \
17
+ --offer "Feedback on onboarding" --email "noor@example.org" > noor.vcf
18
+ ```
19
+
20
+ Open `noor.vcf` in your contacts app, attach it to a message, or give it to an agent that reads contact cards. The command runs locally and writes a UTF-8 vCard 3.0 to standard output. You choose who gets the file.
21
+
22
+ To generate the same card from Python, call `nowtyping.make_card("Noor", "Python developers", offer="Feedback on onboarding", email="noor@example.org")`. It returns the file contents as bytes.
23
+
24
+ [NowTyping](https://nowtyping.com/) is building a social network where people meet through their agents. This tool works on its own with Python 3.9 or later.
@@ -0,0 +1,6 @@
1
+ nowtyping.py,sha256=aD7abPixqmBGSmpS2kIqcUMth5uLlnQc0rjcrqysuns,2853
2
+ nowtyping-0.1.0.dist-info/METADATA,sha256=WXjrmGuJIvRSZmQ2R7BBLzx8vOp9YyyzTmC1M9ZuKEM,1196
3
+ nowtyping-0.1.0.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
4
+ nowtyping-0.1.0.dist-info/entry_points.txt,sha256=40SMiEY6gSxc0hlxZb-gJUwiwUckHPenhYj5xHvrC68,45
5
+ nowtyping-0.1.0.dist-info/top_level.txt,sha256=xd4iHvUQ9ERdN_B_nmJrboQxf7Dkf-W6xtdYBqJayGo,10
6
+ nowtyping-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.8.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ nowtyping = nowtyping:main
@@ -0,0 +1 @@
1
+ nowtyping
nowtyping.py ADDED
@@ -0,0 +1,76 @@
1
+ """Make a portable introduction card for a person or their agent."""
2
+
3
+ import argparse
4
+ import sys
5
+ import unicodedata
6
+ from email.errors import HeaderParseError
7
+ from email.headerregistry import Address
8
+ from typing import Optional
9
+
10
+
11
+ def _field(value: str, label: str) -> str:
12
+ if not value.strip():
13
+ raise ValueError(f"{label} must contain some text")
14
+ if any(unicodedata.category(char) in {"Cc", "Cs", "Zl", "Zp"} for char in value):
15
+ raise ValueError(f"{label} must be one line of text without control characters")
16
+ return value.strip()
17
+
18
+
19
+ def _escape(value: str) -> str:
20
+ return value.replace("\\", "\\\\").replace(";", "\\;").replace(",", "\\,")
21
+
22
+
23
+ def _fold(line: str) -> bytes:
24
+ """Fold at 75 octets, counting the space at the start of a continuation."""
25
+ output = bytearray()
26
+ width = 0
27
+ for char in line:
28
+ encoded = char.encode("utf-8")
29
+ if width + len(encoded) > 75:
30
+ output.extend(b"\r\n ")
31
+ width = 1
32
+ output.extend(encoded)
33
+ width += len(encoded)
34
+ return bytes(output) + b"\r\n"
35
+
36
+
37
+ def make_card(
38
+ name: str, looking_for: str, *, offer: Optional[str] = None, email: Optional[str] = None
39
+ ) -> bytes:
40
+ """Return a UTF-8 vCard 3.0 containing the supplied introduction."""
41
+ name = _escape(_field(name, "name"))
42
+ looking_for = _escape(_field(looking_for, "looking-for"))
43
+ note = f"Looking for: {looking_for}"
44
+ if offer is not None:
45
+ note += r"\nCan offer: " + _escape(_field(offer, "offer"))
46
+
47
+ lines = ["BEGIN:VCARD", "VERSION:3.0", f"FN:{name}", f"N:;{name};;;"]
48
+ if email is not None:
49
+ email = _field(email, "email")
50
+ try:
51
+ address = Address(addr_spec=email)
52
+ except (HeaderParseError, ValueError, IndexError):
53
+ raise ValueError("email must be a single address such as noor@example.org") from None
54
+ if not address.username or not address.domain:
55
+ raise ValueError("email must include a local part and a domain")
56
+ lines.append("EMAIL;TYPE=INTERNET:" + _escape(address.addr_spec))
57
+ lines.extend([f"NOTE:{note}", "END:VCARD"])
58
+ return b"".join(_fold(line) for line in lines)
59
+
60
+
61
+ def main() -> None:
62
+ parser = argparse.ArgumentParser(description=__doc__)
63
+ parser.add_argument("--name", required=True, help="display name to put on the card")
64
+ parser.add_argument("--looking-for", required=True, help="who you would like to meet")
65
+ parser.add_argument("--offer", help="what you can offer in return")
66
+ parser.add_argument("--email", help="contact address to include on the card")
67
+ args = parser.parse_args()
68
+ try:
69
+ card = make_card(args.name, args.looking_for, offer=args.offer, email=args.email)
70
+ except ValueError as error:
71
+ parser.error(str(error))
72
+ sys.stdout.buffer.write(card)
73
+
74
+
75
+ if __name__ == "__main__":
76
+ main()