|
| 1 | +// Copyright 2022 The go-python Authors. All rights reserved. |
| 2 | +// Use of this source code is governed by a BSD-style |
| 3 | +// license that can be found in the LICENSE file. |
| 4 | + |
| 5 | +// Package string provides the implementation of the python's 'string' module. |
| 6 | +package string |
| 7 | + |
| 8 | +import "github.com/go-python/gpython/py" |
| 9 | + |
| 10 | +func init() { |
| 11 | + methods := []*py.Method{ |
| 12 | + // py.MustNewMethod("get_clock_info", time_get_clock_info, 0, get_clock_info_doc), |
| 13 | + } |
| 14 | + |
| 15 | + py.RegisterModule(&py.ModuleImpl{ |
| 16 | + Info: py.ModuleInfo{ |
| 17 | + Name: "string", |
| 18 | + Doc: module_doc, |
| 19 | + }, |
| 20 | + Methods: methods, |
| 21 | + Globals: py.StringDict{ |
| 22 | + "whitespace": whitespace, |
| 23 | + "ascii_lowercase": ascii_lowercase, |
| 24 | + "ascii_uppercase": ascii_uppercase, |
| 25 | + "ascii_letters": ascii_letters, |
| 26 | + "digits": digits, |
| 27 | + "hexdigits": hexdigits, |
| 28 | + "octdigits": octdigits, |
| 29 | + "punctuation": punctuation, |
| 30 | + "printable": printable, |
| 31 | + }, |
| 32 | + }) |
| 33 | +} |
| 34 | + |
| 35 | +const module_doc = `A collection of string constants. |
| 36 | +
|
| 37 | +Public module variables: |
| 38 | +
|
| 39 | +whitespace -- a string containing all ASCII whitespace |
| 40 | +ascii_lowercase -- a string containing all ASCII lowercase letters |
| 41 | +ascii_uppercase -- a string containing all ASCII uppercase letters |
| 42 | +ascii_letters -- a string containing all ASCII letters |
| 43 | +digits -- a string containing all ASCII decimal digits |
| 44 | +hexdigits -- a string containing all ASCII hexadecimal digits |
| 45 | +octdigits -- a string containing all ASCII octal digits |
| 46 | +punctuation -- a string containing all ASCII punctuation characters |
| 47 | +printable -- a string containing all ASCII characters considered printable |
| 48 | +` |
| 49 | + |
| 50 | +var ( |
| 51 | + whitespace = py.String(" \t\n\r\x0b\x0c") |
| 52 | + ascii_lowercase = py.String("abcdefghijklmnopqrstuvwxyz") |
| 53 | + ascii_uppercase = py.String("ABCDEFGHIJKLMNOPQRSTUVWXYZ") |
| 54 | + ascii_letters = ascii_lowercase + ascii_uppercase |
| 55 | + digits = py.String("0123456789") |
| 56 | + hexdigits = py.String("0123456789abcdefABCDEF") |
| 57 | + octdigits = py.String("01234567") |
| 58 | + punctuation = py.String("!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~") |
| 59 | + printable = py.String("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ \t\n\r\x0b\x0c") |
| 60 | +) |
0 commit comments