Lines Matching +full:- +full:- +full:timeout +full:- +full:first +full:- +full:minutes
2 - RFC 977: Network News Transfer Protocol
3 - RFC 2980: Common NNTP Extensions
4 - RFC 3977: Network News Transfer Protocol (version 2)
10 >>> resp, count, first, last, name = s.group('comp.lang.python')
11 >>> print('Group', name, 'has', count, 'articles, range', first, 'to', last)
13 >>> resp, subs = s.xhdr('subject', '{0}-{1}'.format(first, last))
34 # - all commands are encoded as UTF-8 data (using the "surrogateescape"
36 # - all responses are decoded as UTF-8 data (using the "surrogateescape"
38 # - the `file` argument to various methods is keyword-only
40 # - NNTP.date() returns a datetime object
41 # - NNTP.newgroups() and NNTP.newnews() take a datetime (or date) object,
43 # - NNTP.newgroups() and NNTP.list() return a list of GroupInfo named tuples
44 # - NNTP.descriptions() returns a dict mapping group names to descriptions
45 # - NNTP.xover() returns a list of dicts mapping field names (header or metadata)
47 # - NNTP.article(), NNTP.head() and NNTP.body() return a (response, ArticleInfo)
49 # - the "internal" methods have been marked private (they now start with
53 # - automatic querying of capabilities at connect
54 # - New method NNTP.getcapabilities()
55 # - New method NNTP.over()
56 # - New helper function decode_header()
57 # - NNTP.post() and NNTP.ihave() accept file objects, bytes-like objects and
59 # - An extensive test suite :-)
62 # - return structured data (GroupInfo etc.) everywhere
63 # - support HDR
121 """Response does not begin with [1-5]"""
137 '211', # LISTGROUP (also not multi-line with GROUP)
151 "subject", "from", "date", "message-id", "references", ":bytes", ":lines"]
163 ['group', 'last', 'first', 'flag'])
172 and decodes it as a (possibly non-ASCII) readable value."""
224 # Non-default header names are included in full in the response
241 time_str = date_str[-6:]
242 date_str = date_str[:-6]
244 minutes = int(time_str[2:4])
246 year = int(date_str[:-4])
247 month = int(date_str[-4:-2])
248 day = int(date_str[-2:])
249 # RFC 3977 doesn't say how to interpret 2-char years. Assume that
255 return datetime.datetime(year, month, day, hours, minutes, seconds)
287 - sock: Socket to wrap
288 - context: SSL context to use for the encrypted connection
290 - sock: New, encrypted socket.
300 # UTF-8 is the character set for all NNTP commands and responses: they
303 # However, some multi-line data blocks can contain arbitrary bytes (for
304 # example, latin-1 or utf-16 data in the body of a message). Commands
307 # Furthermore, since there could be non-compliant servers out there,
309 # and easy round-tripping. This could be useful for some applications
312 encoding = 'utf-8'
317 timeout=_GLOBAL_DEFAULT_TIMEOUT): argument
319 - host: hostname to connect to
320 - port: port to connect to (default the standard NNTP port)
321 - user: username to authenticate with
322 - password: password to use with username
323 - readermode: if true, send 'mode reader' command after
325 - usenetrc: allow loading username and password from ~/.netrc file
327 - timeout: timeout (in seconds) used for socket connections
331 reader-specific commands, such as `group'. If you get
337 self.sock = self._create_socket(timeout)
398 def _create_socket(self, timeout): argument
399 if timeout is not None and not timeout:
400 raise ValueError('Non-blocking socket (timeout=0) is not supported')
402 return socket.create_connection((self.host, self.port), timeout)
446 The `line` must be a bytes-like object."""
471 if line[-2:] == _CRLF:
472 line = line[:-2]
473 elif line[-1:] in _CRLF:
474 line = line[:-1]
499 If `file` is a file-like object, it must be open in binary mode.
579 # Parse lines into "group last first flag"
585 - resp: server response if successful
586 - caps: a dictionary mapping capability names to lists of tokens
598 - date: a date or datetime object
600 - resp: server response if successful
601 - list: list of newsgroup names
614 - group: group name or '*'
615 - date: a date or datetime object
617 - resp: server response if successful
618 - list: list of message ids
630 - group_pattern: a pattern indicating which groups to query
631 - file: Filename string or file object to store the result in
633 - resp: server response if successful
634 - list: list of (group, last, first, flag) (strings)
645 # Try the more std (acc. to RFC2980) LIST NEWSGROUPS first
668 group matches ('group' is a pattern), return the first. If no
685 - group: the group name
687 - resp: server response if successful
688 - count: number of articles
689 - first: first article number
690 - last: last article number
691 - name: the group name
697 count = first = last = 0
702 first = words[2]
707 return resp, int(count), int(first), int(last), name
711 - file: Filename string or file object to store the result in
713 - resp: server response if successful
714 - list: list of strings returned by the server in response to the
736 - message_spec: article number or message id (if not specified,
739 - resp: server response if successful
740 - art_num: the article number
741 - message_id: the message id
764 - message_spec: article number or message id
765 - file: filename string or file object to store the headers in
767 - resp: server response if successful
768 - ArticleInfo: (article number, message id, list of header lines)
778 - message_spec: article number or message id
779 - file: filename string or file object to store the body in
781 - resp: server response if successful
782 - ArticleInfo: (article number, message id, list of body lines)
792 - message_spec: article number or message id
793 - file: filename string or file object to store the article in
795 - resp: server response if successful
796 - ArticleInfo: (article number, message id, list of article lines)
806 - resp: server response if successful
812 - hdr: the header type (e.g. 'subject')
813 - str: an article nr, a message id, or a range nr1-nr2
814 - file: Filename string or file object to store the result in
816 - resp: server response if successful
817 - list: list of (nr, value) strings
819 pat = re.compile('^([0-9]+) ?(.*)\n?')
828 - start: start of range
829 - end: end of range
830 - file: Filename string or file object to store the result in
832 - resp: server response if successful
833 - list: list of dicts containing the response fields
835 resp, lines = self._longcmdstring('XOVER {0}-{1}'.format(start, end),
843 - message_spec:
844 - either a message id, indicating the article to fetch
846 - or a (start, end) tuple, indicating a range of article numbers;
849 - or None, indicating the current article number must be used
850 - file: Filename string or file object to store the result in
852 - resp: server response if successful
853 - list: list of dicts containing the response fields
860 cmd += ' {0}-{1}'.format(start, end or '')
870 - resp: server response if successful
871 - date: datetime object
892 # - we don't want additional CRLF if the file or iterable is already
894 # - we don't want a spurious flush() after each line is written
907 - data: bytes object, iterable or file containing the article
909 - resp: server response if successful"""
914 - message_id: message-id of the article
915 - data: file containing the article
917 - resp: server response if successful
931 - resp: server response if successful"""
995 - context: SSL context to use for the encrypted connection
1023 timeout=_GLOBAL_DEFAULT_TIMEOUT): argument
1029 usenetrc, timeout)
1031 def _create_socket(self, timeout): argument
1032 sock = super()._create_socket(timeout)
1049 nntplib built-in demo - display the latest articles in a newsgroup""")
1050 parser.add_argument('-g', '--group', default='gmane.comp.python.general',
1052 parser.add_argument('-s', '--server', default='news.gmane.io',
1054 parser.add_argument('-p', '--port', default=-1, type=int,
1056 parser.add_argument('-n', '--nb-articles', default=10, type=int,
1058 parser.add_argument('-S', '--ssl', action='store_true', default=False,
1064 if port == -1:
1068 if port == -1:
1075 resp, count, first, last, name = s.group(args.group) variable
1076 print('Group', name, 'has', count, 'articles, range', first, 'to', last)
1080 s = s[:lim - 4] + "..."
1083 first = str(int(last) - args.nb_articles + 1) variable
1084 resp, overviews = s.xover(first, last)