Lines Matching +full:not +full:- +full:date
2 - RFC 977: Network News Transfer Protocol
3 - RFC 2980: Common NNTP Extensions
4 - RFC 3977: Network News Transfer Protocol (version 2)
13 >>> resp, subs = s.xhdr('subject', '{0}-{1}'.format(first, last))
27 are strings, not numbers, since they are rarely used for calculations.
31 # xover, xgtitle, xpath, date methods by Kevan Heydon
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,
42 # rather than a pair of (date, time) strings.
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)
149 # Default decoded value for LIST OVERVIEW.FMT if not supported
151 "subject", "from", "date", "message-id", "references", ":bytes", ":lines"]
172 and decodes it as a (possibly non-ASCII) readable value."""
184 Raises NNTPDataError if the response is not compliant
217 # XXX should we raise an error? Some servers might not
223 if i >= n_defaults and not is_metadata:
224 # Non-default header names are included in full in the response
236 """Parse a pair of (date, time) strings, and return a datetime object.
237 If only the date is given, it is assumed to be date and time
238 concatenated together (e.g. response to the DATE command).
241 time_str = date_str[-6:]
242 date_str = date_str[:-6]
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
258 """Format a date or datetime object as a pair of (date, time) strings
260 date object is passed, the time is assumed to be midnight (00h00).
264 date has the YYYYMMDD format and time the HHMMSS format
266 date has the YYMMDD format and time the HHMMSS format.
270 if not isinstance(dt, datetime.datetime):
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'
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
326 if not specified explicitly
327 - timeout: timeout (in seconds) used for socket connections
331 reader-specific commands, such as `group'. If you get
367 # Enable only if we're not already in READER mode anyway.
369 if readermode and 'READER' not in self._caps:
371 if not self.readermode_afterauth:
377 # a TLS session active. A client MUST NOT attempt to start a TLS
399 if timeout is not None and not timeout:
400 raise ValueError('Non-blocking socket (timeout=0) is not supported')
408 if it 201, posting is not allowed."""
415 If the CAPABILITIES command is not supported, an empty dict is
438 1: print commands and responses but not body text etc.
446 The `line` must be a bytes-like object."""
469 if not line: raise EOFError
471 if line[-2:] == _CRLF:
472 line = line[:-2]
473 elif line[-1:] in _CRLF:
474 line = line[:-1]
489 if c not in '123':
499 If `file` is a file-like object, it must be open in binary mode.
509 if resp[:3] not in _LONGRESP:
513 if file is not None:
562 """Internal: get the overview format. Queries the server if not
571 # Not supported by server?
583 """Process a CAPABILITIES command. Not supported by all servers.
585 - resp: server response if successful
586 - caps: a dictionary mapping capability names to lists of tokens
596 def newgroups(self, date, *, file=None): argument
598 - date: a date or datetime object
600 - resp: server response if successful
601 - list: list of newsgroup names
603 if not isinstance(date, (datetime.date, datetime.date)):
605 "the date parameter must be a date or datetime object, "
606 "not '{:40}'".format(date.__class__.__name__))
607 date_str, time_str = _unparse_datetime(date, self.nntp_version < 2)
612 def newnews(self, group, date, *, file=None): argument
614 - group: group name or '*'
615 - date: a date or datetime object
617 - resp: server response if successful
618 - list: list of message ids
620 if not isinstance(date, (datetime.date, datetime.date)):
622 "the date parameter must be a date or datetime object, "
623 "not '{:40}'".format(date.__class__.__name__))
624 date_str, time_str = _unparse_datetime(date, self.nntp_version < 2)
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)
636 if group_pattern is not None:
647 if not resp.startswith('215'):
657 if not return_all:
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
694 if not resp.startswith('211'):
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
722 if not resp.startswith('22'):
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)
770 if message_spec is not None:
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)
784 if message_spec is not None:
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)
798 if message_spec is not None:
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 '')
861 elif message_spec is not None:
867 def date(self): member in NNTP
868 """Process the DATE command.
870 - resp: server response if successful
871 - date: datetime object
873 resp = self._shortcmd("DATE")
874 if not resp.startswith('111'):
879 date = elem[1]
880 if len(date) != 14:
882 return resp, _parse_datetime(date, None)
886 # Raises a specific exception if posting is not allowed
887 if not resp.startswith('3'):
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
896 if not line.endswith(_CRLF):
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"""
941 if not user and not usenetrc:
948 if usenetrc and not user:
958 if not user:
962 if not password:
966 if not resp.startswith('281'):
972 # Only do so if we're not in reader mode already.
973 if self.readermode_afterauth and 'READER' not in self._caps:
983 # Error 5xx, probably 'not implemented'
995 - context: SSL context to use for the encrypted connection
997 # Per RFC 4642, STARTTLS MUST NOT be sent after authentication or if
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,
1063 if not args.ssl:
1064 if port == -1:
1068 if port == -1:
1080 s = s[:lim - 4] + "..."
1083 first = str(int(last) - args.nb_articles + 1)