/usr/share/doc/python-logilab-common/apidoc/logilab.common.textutils-module.html is in python-logilab-common 1.1.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 | <?xml version="1.0" encoding="ascii"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>logilab.common.textutils</title>
<link rel="stylesheet" href="epydoc.css" type="text/css" />
<script type="text/javascript" src="epydoc.js"></script>
</head>
<body bgcolor="white" text="black" link="blue" vlink="#204080"
alink="#204080">
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
bgcolor="#a0c0ff" cellspacing="0">
<tr valign="middle">
<!-- Home link -->
<th> <a
href="logilab.common-module.html">Home</a> </th>
<!-- Tree link -->
<th> <a
href="module-tree.html">Trees</a> </th>
<!-- Index link -->
<th> <a
href="identifier-index.html">Indices</a> </th>
<!-- Help link -->
<th> <a
href="help.html">Help</a> </th>
<!-- Project homepage -->
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center"
>Logilab's common library</th>
</tr></table></th>
</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="100%">
<span class="breadcrumbs">
Package logilab ::
<a href="logilab.common-module.html">Package common</a> ::
Module textutils
</span>
</td>
<td>
<table cellpadding="0" cellspacing="0">
<!-- hide/show private -->
<tr><td align="right"><span class="options"
>[<a href="frames.html" target="_top">frames</a
>] | <a href="logilab.common.textutils-module.html"
target="_top">no frames</a>]</span></td></tr>
</table>
</td>
</tr>
</table>
<!-- ==================== MODULE DESCRIPTION ==================== -->
<h1 class="epydoc">Module textutils</h1><p class="nomargin-top"><span class="codelink"><a href="logilab.common.textutils-pysrc.html">source code</a></span></p>
<pre class="literalblock">
Some text manipulation utility functions.
:group text formatting: normalize_text, normalize_paragraph, pretty_match,unquote, colorize_ansi
:group text manipulation: searchall, splitstrip
:sort: text formatting, text manipulation
:type ANSI_STYLES: dict(str)
:var ANSI_STYLES: dictionary mapping style identifier to ANSI terminal code
:type ANSI_COLORS: dict(str)
:var ANSI_COLORS: dictionary mapping color identifier to ANSI terminal code
:type ANSI_PREFIX: str
:var ANSI_PREFIX:
ANSI terminal code notifying the start of an ANSI escape sequence
:type ANSI_END: str
:var ANSI_END:
ANSI terminal code notifying the end of an ANSI escape sequence
:type ANSI_RESET: str
:var ANSI_RESET:
ANSI terminal code resetting format defined by a previous ANSI escape sequence
</pre>
<!-- ==================== FUNCTIONS ==================== -->
<a name="section-Functions"></a>
<table class="summary" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td align="left" colspan="2" class="table-header">
<span class="table-header">Functions</span></td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="logilab.common.textutils-module.html#unormalize" class="summary-sig-name">unormalize</a>(<span class="summary-sig-arg">ustring</span>,
<span class="summary-sig-arg">ignorenonascii</span>=<span class="summary-sig-default">None</span>,
<span class="summary-sig-arg">substitute</span>=<span class="summary-sig-default">None</span>)</span><br />
replace diacritical characters with their corresponding ascii characters</td>
<td align="right" valign="top">
<span class="codelink"><a href="logilab.common.textutils-pysrc.html#unormalize">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="logilab.common.textutils-module.html#unquote" class="summary-sig-name">unquote</a>(<span class="summary-sig-arg">string</span>)</span><br />
remove optional quotes (simple or double) from the string</td>
<td align="right" valign="top">
<span class="codelink"><a href="logilab.common.textutils-pysrc.html#unquote">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="logilab.common.textutils-module.html#normalize_text" class="summary-sig-name">normalize_text</a>(<span class="summary-sig-arg">text</span>,
<span class="summary-sig-arg">line_len</span>=<span class="summary-sig-default">80</span>,
<span class="summary-sig-arg">indent</span>=<span class="summary-sig-default">''</span>,
<span class="summary-sig-arg">rest</span>=<span class="summary-sig-default">False</span>)</span><br />
normalize a text to display it with a maximum line size and
optionally arbitrary indentation.</td>
<td align="right" valign="top">
<span class="codelink"><a href="logilab.common.textutils-pysrc.html#normalize_text">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="logilab.common.textutils-module.html#normalize_paragraph" class="summary-sig-name">normalize_paragraph</a>(<span class="summary-sig-arg">text</span>,
<span class="summary-sig-arg">line_len</span>=<span class="summary-sig-default">80</span>,
<span class="summary-sig-arg">indent</span>=<span class="summary-sig-default">''</span>)</span><br />
normalize a text to display it with a maximum line size and
optionally arbitrary indentation.</td>
<td align="right" valign="top">
<span class="codelink"><a href="logilab.common.textutils-pysrc.html#normalize_paragraph">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="logilab.common.textutils-module.html#normalize_rest_paragraph" class="summary-sig-name">normalize_rest_paragraph</a>(<span class="summary-sig-arg">text</span>,
<span class="summary-sig-arg">line_len</span>=<span class="summary-sig-default">80</span>,
<span class="summary-sig-arg">indent</span>=<span class="summary-sig-default">''</span>)</span><br />
normalize a ReST text to display it with a maximum line size and
optionally arbitrary indentation.</td>
<td align="right" valign="top">
<span class="codelink"><a href="logilab.common.textutils-pysrc.html#normalize_rest_paragraph">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="logilab.common.textutils-module.html#splittext" class="summary-sig-name">splittext</a>(<span class="summary-sig-arg">text</span>,
<span class="summary-sig-arg">line_len</span>)</span><br />
split the given text on space according to the given max line size</td>
<td align="right" valign="top">
<span class="codelink"><a href="logilab.common.textutils-pysrc.html#splittext">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="logilab.common.textutils-module.html#splitstrip" class="summary-sig-name">splitstrip</a>(<span class="summary-sig-arg">string</span>,
<span class="summary-sig-arg">sep</span>=<span class="summary-sig-default">','</span>)</span><br />
return a list of stripped string by splitting the string given as
argument on `sep` (',' by default).</td>
<td align="right" valign="top">
<span class="codelink"><a href="logilab.common.textutils-pysrc.html#splitstrip">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="logilab.common.textutils-module.html#split_url_or_path" class="summary-sig-name">split_url_or_path</a>(<span class="summary-sig-arg">url_or_path</span>)</span><br />
return the latest component of a string containing either an url of the...</td>
<td align="right" valign="top">
<span class="codelink"><a href="logilab.common.textutils-pysrc.html#split_url_or_path">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="logilab.common.textutils-module.html#text_to_dict" class="summary-sig-name">text_to_dict</a>(<span class="summary-sig-arg">text</span>)</span><br />
parse multilines text containing simple 'key=value' lines and return a
dict of {'key': 'value'}.</td>
<td align="right" valign="top">
<span class="codelink"><a href="logilab.common.textutils-pysrc.html#text_to_dict">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="logilab.common.textutils-module.html#apply_units" class="summary-sig-name">apply_units</a>(<span class="summary-sig-arg">string</span>,
<span class="summary-sig-arg">units</span>,
<span class="summary-sig-arg">inter</span>=<span class="summary-sig-default">None</span>,
<span class="summary-sig-arg">final</span>=<span class="summary-sig-default">float</span>,
<span class="summary-sig-arg">blank_reg</span>=<span class="summary-sig-default">_BLANK_RE</span>,
<span class="summary-sig-arg">value_reg</span>=<span class="summary-sig-default">_VALUE_RE</span>)</span><br />
Parse the string applying the units defined in units
(e.g.: "1.5m",{'m',60} -> 80).</td>
<td align="right" valign="top">
<span class="codelink"><a href="logilab.common.textutils-pysrc.html#apply_units">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="logilab.common.textutils-module.html#pretty_match" class="summary-sig-name">pretty_match</a>(<span class="summary-sig-arg">match</span>,
<span class="summary-sig-arg">string</span>,
<span class="summary-sig-arg">underline_char</span>=<span class="summary-sig-default">'^'</span>)</span><br />
return a string with the match location underlined:</td>
<td align="right" valign="top">
<span class="codelink"><a href="logilab.common.textutils-pysrc.html#pretty_match">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a href="logilab.common.textutils-module.html#colorize_ansi" class="summary-sig-name">colorize_ansi</a>(<span class="summary-sig-arg">msg</span>,
<span class="summary-sig-arg">color</span>=<span class="summary-sig-default">None</span>,
<span class="summary-sig-arg">style</span>=<span class="summary-sig-default">None</span>)</span><br />
colorize message by wrapping it with ansi escape codes</td>
<td align="right" valign="top">
<span class="codelink"><a href="logilab.common.textutils-pysrc.html#colorize_ansi">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td><span class="summary-sig"><a name="diff_colorize_ansi"></a><span class="summary-sig-name">diff_colorize_ansi</span>(<span class="summary-sig-arg">lines</span>,
<span class="summary-sig-arg">out</span>=<span class="summary-sig-default">sys.stdout</span>,
<span class="summary-sig-arg">style</span>=<span class="summary-sig-default">DIFF_STYLE</span>)</span></td>
<td align="right" valign="top">
<span class="codelink"><a href="logilab.common.textutils-pysrc.html#diff_colorize_ansi">source code</a></span>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- ==================== VARIABLES ==================== -->
<a name="section-Variables"></a>
<table class="summary" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td align="left" colspan="2" class="table-header">
<span class="table-header">Variables</span></td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="linesep"></a><span class="summary-name">linesep</span> = <code title="'\n'">'\n'</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="logilab.common.textutils-module.html#MANUAL_UNICODE_MAP" class="summary-name">MANUAL_UNICODE_MAP</a> = <code title="{u'\xa1': u'!', u'\u0142': u'l', u'\u2044': u'/', u'\xc6': u'AE', u'\x\
a9': u'(c)', u'\xab': u'"', u'\xe6': u'ae', u'\xae': u'(r)', u'\u0153'\
: u'oe', u'\u0152': u'OE', u'\xd8': u'O', u'\xf8': u'o', u'\xbb': u'"'\
, u'\xdf': u'ss',}">{u'\xa1': u'!', u'\u0142': u'l', u'\u2044<code class="variable-ellipsis">...</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="logilab.common.textutils-module.html#get_csv" class="summary-name">get_csv</a> = <code title="deprecated('get_csv is deprecated, use splitstrip')(splitstrip)">deprecated('get_csv is deprecated, use splitstrip')(<code class="variable-ellipsis">...</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="logilab.common.textutils-module.html#BYTE_UNITS" class="summary-name">BYTE_UNITS</a> = <code title="{"b": 1, "kb": 1024, "mb": 1024** 2, "gb": 1024** 3, "tb": 1024** 4,}">{"b": 1, "kb": 1024, "mb": 1024** 2, "gb": 1024**<code class="variable-ellipsis">...</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="logilab.common.textutils-module.html#TIME_UNITS" class="summary-name">TIME_UNITS</a> = <code title="{"ms": 0.0001, "s": 1, "min": 60, "h": 60* 60, "d": 60* 60* 24,}">{"ms": 0.0001, "s": 1, "min": 60, "h": 60* 60, "d<code class="variable-ellipsis">...</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="ANSI_PREFIX"></a><span class="summary-name">ANSI_PREFIX</span> = <code title="'\033['">'\033['</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="ANSI_END"></a><span class="summary-name">ANSI_END</span> = <code title="'m'">'m'</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a name="ANSI_RESET"></a><span class="summary-name">ANSI_RESET</span> = <code title="'\033[0m'">'\033[0m'</code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="logilab.common.textutils-module.html#ANSI_STYLES" class="summary-name">ANSI_STYLES</a> = <code title="{'reset': "0", 'bold': "1", 'italic': "3", 'underline': "4", 'blink': \
"5", 'inverse': "7", 'strike': "9",}">{'reset': "0", 'bold': "1", 'italic': "3", 'unde<code class="variable-ellipsis">...</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="logilab.common.textutils-module.html#ANSI_COLORS" class="summary-name">ANSI_COLORS</a> = <code title="{'reset': "0", 'black': "30", 'red': "31", 'green': "32", 'yellow': "3\
3", 'blue': "34", 'magenta': "35", 'cyan': "36", 'white': "37",}">{'reset': "0", 'black': "30", 'red': "31", 'gree<code class="variable-ellipsis">...</code></code>
</td>
</tr>
<tr>
<td width="15%" align="right" valign="top" class="summary">
<span class="summary-type"> </span>
</td><td class="summary">
<a href="logilab.common.textutils-module.html#DIFF_STYLE" class="summary-name">DIFF_STYLE</a> = <code title="{'separator': 'cyan', 'remove': 'red', 'add': 'green'}">{'separator': 'cyan', 'remove': 'red', 'add': 'gr<code class="variable-ellipsis">...</code></code>
</td>
</tr>
</table>
<!-- ==================== FUNCTION DETAILS ==================== -->
<a name="section-FunctionDetails"></a>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td align="left" colspan="2" class="table-header">
<span class="table-header">Function Details</span></td>
</tr>
</table>
<a name="unormalize"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">unormalize</span>(<span class="sig-arg">ustring</span>,
<span class="sig-arg">ignorenonascii</span>=<span class="sig-default">None</span>,
<span class="sig-arg">substitute</span>=<span class="sig-default">None</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="logilab.common.textutils-pysrc.html#unormalize">source code</a></span>
</td>
</tr></table>
<pre class="literalblock">
replace diacritical characters with their corresponding ascii characters
Convert the unicode string to its long normalized form (unicode character
will be transform into several characters) and keep the first one only.
The normal form KD (NFKD) will apply the compatibility decomposition, i.e.
replace all compatibility characters with their equivalents.
:type substitute: str
:param substitute: replacement character to use if decomposition fails
:see: Another project about ASCII transliterations of Unicode text
http://pypi.python.org/pypi/Unidecode
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="unquote"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">unquote</span>(<span class="sig-arg">string</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="logilab.common.textutils-pysrc.html#unquote">source code</a></span>
</td>
</tr></table>
<pre class="literalblock">
remove optional quotes (simple or double) from the string
:type string: str or unicode
:param string: an optionally quoted string
:rtype: str or unicode
:return: the unquoted string (or the input string if it wasn't quoted)
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="normalize_text"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">normalize_text</span>(<span class="sig-arg">text</span>,
<span class="sig-arg">line_len</span>=<span class="sig-default">80</span>,
<span class="sig-arg">indent</span>=<span class="sig-default">''</span>,
<span class="sig-arg">rest</span>=<span class="sig-default">False</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="logilab.common.textutils-pysrc.html#normalize_text">source code</a></span>
</td>
</tr></table>
<pre class="literalblock">
normalize a text to display it with a maximum line size and
optionally arbitrary indentation. Line jumps are normalized but blank
lines are kept. The indentation string may be used to insert a
comment (#) or a quoting (>) mark for instance.
:type text: str or unicode
:param text: the input text to normalize
:type line_len: int
:param line_len: expected maximum line's length, default to 80
:type indent: str or unicode
:param indent: optional string to use as indentation
:rtype: str or unicode
:return:
the input text normalized to fit on lines with a maximized size
inferior to `line_len`, and optionally prefixed by an
indentation string
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="normalize_paragraph"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">normalize_paragraph</span>(<span class="sig-arg">text</span>,
<span class="sig-arg">line_len</span>=<span class="sig-default">80</span>,
<span class="sig-arg">indent</span>=<span class="sig-default">''</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="logilab.common.textutils-pysrc.html#normalize_paragraph">source code</a></span>
</td>
</tr></table>
<pre class="literalblock">
normalize a text to display it with a maximum line size and
optionally arbitrary indentation. Line jumps are normalized. The
indentation string may be used top insert a comment mark for
instance.
:type text: str or unicode
:param text: the input text to normalize
:type line_len: int
:param line_len: expected maximum line's length, default to 80
:type indent: str or unicode
:param indent: optional string to use as indentation
:rtype: str or unicode
:return:
the input text normalized to fit on lines with a maximized size
inferior to `line_len`, and optionally prefixed by an
indentation string
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="normalize_rest_paragraph"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">normalize_rest_paragraph</span>(<span class="sig-arg">text</span>,
<span class="sig-arg">line_len</span>=<span class="sig-default">80</span>,
<span class="sig-arg">indent</span>=<span class="sig-default">''</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="logilab.common.textutils-pysrc.html#normalize_rest_paragraph">source code</a></span>
</td>
</tr></table>
<pre class="literalblock">
normalize a ReST text to display it with a maximum line size and
optionally arbitrary indentation. Line jumps are normalized. The
indentation string may be used top insert a comment mark for
instance.
:type text: str or unicode
:param text: the input text to normalize
:type line_len: int
:param line_len: expected maximum line's length, default to 80
:type indent: str or unicode
:param indent: optional string to use as indentation
:rtype: str or unicode
:return:
the input text normalized to fit on lines with a maximized size
inferior to `line_len`, and optionally prefixed by an
indentation string
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="splittext"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">splittext</span>(<span class="sig-arg">text</span>,
<span class="sig-arg">line_len</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="logilab.common.textutils-pysrc.html#splittext">source code</a></span>
</td>
</tr></table>
<pre class="literalblock">
split the given text on space according to the given max line size
return a 2-uple:
* a line <= line_len if possible
* the rest of the text which has to be reported on another line
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="splitstrip"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">splitstrip</span>(<span class="sig-arg">string</span>,
<span class="sig-arg">sep</span>=<span class="sig-default">','</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="logilab.common.textutils-pysrc.html#splitstrip">source code</a></span>
</td>
</tr></table>
<pre class="literalblock">
return a list of stripped string by splitting the string given as
argument on `sep` (',' by default). Empty string are discarded.
>>> splitstrip('a, b, c , 4,,')
['a', 'b', 'c', '4']
>>> splitstrip('a')
['a']
>>>
:type string: str or unicode
:param string: a csv line
:type sep: str or unicode
:param sep: field separator, default to the comma (',')
:rtype: str or unicode
:return: the unquoted string (or the input string if it wasn't quoted)
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="split_url_or_path"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">split_url_or_path</span>(<span class="sig-arg">url_or_path</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="logilab.common.textutils-pysrc.html#split_url_or_path">source code</a></span>
</td>
</tr></table>
<pre class="literalblock">
return the latest component of a string containing either an url of the
form <scheme>://<path> or a local file system path
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="text_to_dict"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">text_to_dict</span>(<span class="sig-arg">text</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="logilab.common.textutils-pysrc.html#text_to_dict">source code</a></span>
</td>
</tr></table>
<pre class="literalblock">
parse multilines text containing simple 'key=value' lines and return a
dict of {'key': 'value'}. When the same key is encountered multiple time,
value is turned into a list containing all values.
>>> d = text_to_dict('''multiple=1
... multiple= 2
... single =3
... ''')
>>> d['single']
'3'
>>> d['multiple']
['1', '2']
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="apply_units"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">apply_units</span>(<span class="sig-arg">string</span>,
<span class="sig-arg">units</span>,
<span class="sig-arg">inter</span>=<span class="sig-default">None</span>,
<span class="sig-arg">final</span>=<span class="sig-default">float</span>,
<span class="sig-arg">blank_reg</span>=<span class="sig-default">_BLANK_RE</span>,
<span class="sig-arg">value_reg</span>=<span class="sig-default">_VALUE_RE</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="logilab.common.textutils-pysrc.html#apply_units">source code</a></span>
</td>
</tr></table>
<pre class="literalblock">
Parse the string applying the units defined in units
(e.g.: "1.5m",{'m',60} -> 80).
:type string: str or unicode
:param string: the string to parse
:type units: dict (or any object with __getitem__ using basestring key)
:param units: a dict mapping a unit string repr to its value
:type inter: type
:param inter: used to parse every intermediate value (need __sum__)
:type blank_reg: regexp
:param blank_reg: should match every blank char to ignore.
:type value_reg: regexp with "value" and optional "unit" group
:param value_reg: match a value and it's unit into the
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="pretty_match"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">pretty_match</span>(<span class="sig-arg">match</span>,
<span class="sig-arg">string</span>,
<span class="sig-arg">underline_char</span>=<span class="sig-default">'^'</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="logilab.common.textutils-pysrc.html#pretty_match">source code</a></span>
</td>
</tr></table>
<pre class="literalblock">
return a string with the match location underlined:
>>> import re
>>> print(pretty_match(re.search('mange', 'il mange du bacon'), 'il mange du bacon'))
il mange du bacon
^^^^^
>>>
:type match: _sre.SRE_match
:param match: object returned by re.match, re.search or re.finditer
:type string: str or unicode
:param string:
the string on which the regular expression has been applied to
obtain the `match` object
:type underline_char: str or unicode
:param underline_char:
character to use to underline the matched section, default to the
carret '^'
:rtype: str or unicode
:return:
the original string with an inserted line to underline the match
location
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<a name="colorize_ansi"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr valign="top"><td>
<h3 class="epydoc"><span class="sig"><span class="sig-name">colorize_ansi</span>(<span class="sig-arg">msg</span>,
<span class="sig-arg">color</span>=<span class="sig-default">None</span>,
<span class="sig-arg">style</span>=<span class="sig-default">None</span>)</span>
</h3>
</td><td align="right" valign="top"
><span class="codelink"><a href="logilab.common.textutils-pysrc.html#colorize_ansi">source code</a></span>
</td>
</tr></table>
<pre class="literalblock">
colorize message by wrapping it with ansi escape codes
:type msg: str or unicode
:param msg: the message string to colorize
:type color: str or None
:param color:
the color identifier (see `ANSI_COLORS` for available values)
:type style: str or None
:param style:
style string (see `ANSI_COLORS` for available values). To get
several style effects at the same time, use a coma as separator.
:raise KeyError: if an unexistent color or style identifier is given
:rtype: str or unicode
:return: the ansi escaped string
</pre>
<dl class="fields">
</dl>
</td></tr></table>
</div>
<br />
<!-- ==================== VARIABLES DETAILS ==================== -->
<a name="section-VariablesDetails"></a>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr bgcolor="#70b0f0" class="table-header">
<td align="left" colspan="2" class="table-header">
<span class="table-header">Variables Details</span></td>
</tr>
</table>
<a name="MANUAL_UNICODE_MAP"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<h3 class="epydoc">MANUAL_UNICODE_MAP</h3>
<dl class="fields">
</dl>
<dl class="fields">
<dt>Value:</dt>
<dd><table><tr><td><pre class="variable">
{u'\xa1': u'!', u'\u0142': u'l', u'\u2044': u'/', u'\xc6': u'AE', u'\x<span class="variable-linewrap"><img src="crarr.png" alt="\" /></span>
a9': u'(c)', u'\xab': u'"', u'\xe6': u'ae', u'\xae': u'(r)', u'\u0153'<span class="variable-linewrap"><img src="crarr.png" alt="\" /></span>
: u'oe', u'\u0152': u'OE', u'\xd8': u'O', u'\xf8': u'o', u'\xbb': u'"'<span class="variable-linewrap"><img src="crarr.png" alt="\" /></span>
, u'\xdf': u'ss',}
</pre></td></tr></table>
</dd>
</dl>
</td></tr></table>
</div>
<a name="get_csv"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<h3 class="epydoc">get_csv</h3>
<dl class="fields">
</dl>
<dl class="fields">
<dt>Value:</dt>
<dd><table><tr><td><pre class="variable">
deprecated('get_csv is deprecated, use splitstrip')(splitstrip)
</pre></td></tr></table>
</dd>
</dl>
</td></tr></table>
</div>
<a name="BYTE_UNITS"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<h3 class="epydoc">BYTE_UNITS</h3>
<dl class="fields">
</dl>
<dl class="fields">
<dt>Value:</dt>
<dd><table><tr><td><pre class="variable">
{"b": 1, "kb": 1024, "mb": 1024** 2, "gb": 1024** 3, "tb": 1024** 4,}
</pre></td></tr></table>
</dd>
</dl>
</td></tr></table>
</div>
<a name="TIME_UNITS"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<h3 class="epydoc">TIME_UNITS</h3>
<dl class="fields">
</dl>
<dl class="fields">
<dt>Value:</dt>
<dd><table><tr><td><pre class="variable">
{"ms": 0.0001, "s": 1, "min": 60, "h": 60* 60, "d": 60* 60* 24,}
</pre></td></tr></table>
</dd>
</dl>
</td></tr></table>
</div>
<a name="ANSI_STYLES"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<h3 class="epydoc">ANSI_STYLES</h3>
<dl class="fields">
</dl>
<dl class="fields">
<dt>Value:</dt>
<dd><table><tr><td><pre class="variable">
{'reset': "0", 'bold': "1", 'italic': "3", 'underline': "4", 'blink': <span class="variable-linewrap"><img src="crarr.png" alt="\" /></span>
"5", 'inverse': "7", 'strike': "9",}
</pre></td></tr></table>
</dd>
</dl>
</td></tr></table>
</div>
<a name="ANSI_COLORS"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<h3 class="epydoc">ANSI_COLORS</h3>
<dl class="fields">
</dl>
<dl class="fields">
<dt>Value:</dt>
<dd><table><tr><td><pre class="variable">
{'reset': "0", 'black': "30", 'red': "31", 'green': "32", 'yellow': "3<span class="variable-linewrap"><img src="crarr.png" alt="\" /></span>
3", 'blue': "34", 'magenta': "35", 'cyan': "36", 'white': "37",}
</pre></td></tr></table>
</dd>
</dl>
</td></tr></table>
</div>
<a name="DIFF_STYLE"></a>
<div>
<table class="details" border="1" cellpadding="3"
cellspacing="0" width="100%" bgcolor="white">
<tr><td>
<h3 class="epydoc">DIFF_STYLE</h3>
<dl class="fields">
</dl>
<dl class="fields">
<dt>Value:</dt>
<dd><table><tr><td><pre class="variable">
{'separator': 'cyan', 'remove': 'red', 'add': 'green'}
</pre></td></tr></table>
</dd>
</dl>
</td></tr></table>
</div>
<br />
<!-- ==================== NAVIGATION BAR ==================== -->
<table class="navbar" border="0" width="100%" cellpadding="0"
bgcolor="#a0c0ff" cellspacing="0">
<tr valign="middle">
<!-- Home link -->
<th> <a
href="logilab.common-module.html">Home</a> </th>
<!-- Tree link -->
<th> <a
href="module-tree.html">Trees</a> </th>
<!-- Index link -->
<th> <a
href="identifier-index.html">Indices</a> </th>
<!-- Help link -->
<th> <a
href="help.html">Help</a> </th>
<!-- Project homepage -->
<th class="navbar" align="right" width="100%">
<table border="0" cellpadding="0" cellspacing="0">
<tr><th class="navbar" align="center"
>Logilab's common library</th>
</tr></table></th>
</tr>
</table>
<table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr>
<td align="left" class="footer">
Generated by Epydoc 3.0.1
on Sun Jan 17 22:12:20 2016
</td>
<td align="right" class="footer">
<a target="mainFrame" href="http://epydoc.sourceforge.net"
>http://epydoc.sourceforge.net</a>
</td>
</tr>
</table>
<script type="text/javascript">
<!--
// Private objects are initially displayed (because if
// javascript is turned off then we want them to be
// visible); but by default, we want to hide them. So hide
// them unless we have a cookie that says to show them.
checkCookie();
// -->
</script>
</body>
</html>
|