internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: getpelican/pelican

Issue:
output warning during unknown content replacement
https://github.com/getpelican/pelican/blob/master/pelican/contents.py#L215

output a warning if what is invalid and no substitutions occur because of it



Discussion:

Resolving patch:
diff --git a/pelican/contents.py b/pelican/contents.py
--- a/pelican/contents.py
+++ b/pelican/contents.py
@@ -248,6 +248,11 @@ def replacer(m):
                 origin = '/'.join((siteurl, Category(path, self.settings).url))
             elif what == 'tag':
                 origin = '/'.join((siteurl, Tag(path, self.settings).url))
+            else:
+                logger.warning(
+                        "Replacement Indicator '%s' not recognized, "
+                        "skipping replacement",
+                        what)
 
             # keep all other parts, such as query, fragment, etc.
             parts = list(value)


Test patch:
diff --git a/pelican/tests/test_contents.py b/pelican/tests/test_contents.py
--- a/pelican/tests/test_contents.py
+++ b/pelican/tests/test_contents.py
@@ -1,5 +1,6 @@
 from __future__ import unicode_literals, absolute_import
 
+import logging
 import locale
 import os.path
 import six
@@ -11,7 +12,7 @@
                               Author, Category)
 from pelican.settings import DEFAULT_CONFIG
 from pelican.signals import content_object_init
-from pelican.tests.support import unittest, get_settings
+from pelican.tests.support import LoggedTestCase, mute, unittest, get_settings
 from pelican.utils import (path_to_url, truncate_html_words, SafeDatetime,
                            posix_join)
 
@@ -413,10 +414,10 @@ def test_slugify_category_author(self):
         self.assertEqual(article.save_as, 'obrien/csharp-stuff/fnord/index.html')
 
 
-class TestStatic(unittest.TestCase):
+class TestStatic(LoggedTestCase):
 
     def setUp(self):
-
+        super(TestStatic, self).setUp()
         self.settings = get_settings(
             STATIC_SAVE_AS='{path}',
             STATIC_URL='{path}',
@@ -578,3 +579,20 @@ def test_category_link_syntax(self):
         content = page.get_content('')
 
         self.assertNotEqual(content, html)
+
+    def test_unknown_link_syntax(self):
+        "{unknown} link syntax should trigger warning."
+
+        html = '<a href="{unknown}foo">link</a>'
+        page = Page(content=html,
+                    metadata={'title': 'fakepage'}, settings=self.settings,
+                    source_path=os.path.join('dir', 'otherdir', 'fakepage.md'),
+                    context=self.context)
+        content =  page.get_content('')
+
+        self.assertEqual(content, html)
+        self.assertLogCountEqual(
+                count=1,
+                msg="Replacement Indicator 'unknown' not recognized, "
+                    "skipping replacement",
+                level=logging.WARNING)
Repository: getpelican/pelican

Issue:
Reload settings file when not specified
Explicitly defining a settings file will be reloaded when using the --autoreload option. Using the default will indicate that the settings file is tracked, but will not reload the file when it is changed.



Discussion:

Resolving patch:
diff --git a/pelican/__init__.py b/pelican/__init__.py
--- a/pelican/__init__.py
+++ b/pelican/__init__.py
@@ -277,6 +277,7 @@ def parse_arguments():
                         '"output" in the current path.')
 
     parser.add_argument('-s', '--settings', dest='settings',
+                        default=DEFAULT_CONFIG_NAME,
                         help='The settings of the application, this is '
                         'automatically set to {0} if a file exists with this '
                         'name.'.format(DEFAULT_CONFIG_NAME))


Test patch:
Repository: getpelican/pelican

Issue:
Localize defaults in pelican-quickstart
Now, default language and timezone are hard-coded ('en', 'Europe/Paris').
Use system locale to adjust default values.



Discussion:

Resolving patch:
diff --git a/pelican/tools/pelican_quickstart.py b/pelican/tools/pelican_quickstart.py
--- a/pelican/tools/pelican_quickstart.py
+++ b/pelican/tools/pelican_quickstart.py
@@ -4,12 +4,19 @@
 
 import argparse
 import codecs
+import locale
 import os
 import string
 import sys
 
 import pytz
 
+try:
+    import tzlocal
+    _DEFAULT_TIMEZONE = tzlocal.get_localzone().zone
+except:
+    _DEFAULT_TIMEZONE = 'Europe/Paris'
+
 import six
 
 from pelican import __version__
@@ -42,8 +49,8 @@
     'github_pages_branch': _GITHUB_PAGES_BRANCHES['project'],
     'default_pagination': 10,
     'siteurl': '',
-    'lang': 'en',
-    'timezone': 'Europe/Paris'
+    'lang': locale.getlocale()[0].split('_')[0],
+    'timezone': _DEFAULT_TIMEZONE
 }
 
 # url for list of valid timezones


Test patch:
Repository: getpelican/pelican

Issue:
Unstable markdown extensions order
I tested Pelican with #1927 merged and found one breaking difference with Pelican 3.6.3.

In Pelican 3.6.3 extensions is list, which passed to Markdown as is (with 'meta' added) and all extensions initialized in order. Now it can be dictionary `extension_configs` or list `extensions`. But in any way it will passed through `list(set(settings['extensions']))`. So extensions initialized in arbitrary order and a new order for each Pelican execution. Looks like such behaviour starts even before, with #1638.

I have extensions that depend on some internal parsers and ones from 'abbr' and 'meta' extensions. I can add my parser before or after some internal one, but now I cannot add my parser after one from 'meta' or 'abbr'.

I suggest to removing repeated extensions w/o changing its order or don’t do it at all (just carefully add keys from 'extension_configs' to end of 'extension'). The second way looks better for me.

@Scheirle, do you have time to fix it? I can make PR if it’s needed. Hope it should be fixed before 3.7 will released.


Discussion:

Resolving patch:
diff --git a/pelican/readers.py b/pelican/readers.py
--- a/pelican/readers.py
+++ b/pelican/readers.py
@@ -246,16 +246,14 @@ class MarkdownReader(BaseReader):
 
     def __init__(self, *args, **kwargs):
         super(MarkdownReader, self).__init__(*args, **kwargs)
-        # make sure 'extension_configs' exists and
-        # and either way 'markdown.extensions.meta' must be in there
         settings = self.settings['MARKDOWN']
         settings.setdefault('extension_configs', {})
-        settings['extension_configs'].setdefault(
-            'markdown.extensions.meta', {})
         settings.setdefault('extensions', [])
-        settings['extensions'].extend(
-            list(settings['extension_configs'].keys()))
-        settings['extensions'] = list(set(settings['extensions']))
+        for extension in settings['extension_configs'].keys():
+            if extension not in settings['extensions']:
+                settings['extensions'].append(extension)
+        if 'markdown.extensions.meta' not in settings['extensions']:
+            settings['extensions'].append('markdown.extensions.meta')
         self._source_path = None
 
     def _parse_metadata(self, meta):


Test patch:
Repository: getpelican/pelican

Issue:
Quickstart locale error: 'NoneType' object has no attribute 'split'
Pelican version: 594b9c96 (installed with `pip install -e "git+https://github.com/getpelican/pelican.git#egg=pelican"`)
Python: 2.7.12 Windows x64 (within a virtual environment)
Using:
> blinker (1.4)
docutils (0.12)
feedgenerator (1.9)
Jinja2 (2.8)
Markdown (2.6.7)
MarkupSafe (0.23)
pelican (3.6.4.dev0, d:\documents\pelican\src\pelican)
pip (8.1.2)
Pygments (2.1.3)
python-dateutil (2.5.3)
pytz (2016.7)
setuptools (28.7.1)
six (1.10.0)
smartypants (1.8.6)
typogrify (2.0.7)
Unidecode (0.4.19)
wheel (0.30.0a0)

When invoking `pelican-quickstart`, I am getting the following stacktrace:

>(Pelican) D:\Documents\Pelican>pelican-quickstart
Traceback (most recent call last):
  File "D:\Documents\Pelican\Scripts\pelican-quickstart-script.py", line 11, in <module>
    load_entry_point('pelican', 'console_scripts', 'pelican-quickstart')()
  File "d:\documents\pelican\lib\site-packages\pkg_resources\__init__.py", line 564, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "d:\documents\pelican\lib\site-packages\pkg_resources\__init__.py", line 2608, in load_entry_point
    return ep.load()
  File "d:\documents\pelican\lib\site-packages\pkg_resources\__init__.py", line 2268, in load
    return self.resolve()
  File "d:\documents\pelican\lib\site-packages\pkg_resources\__init__.py", line 2274, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "d:\documents\pelican\src\pelican\pelican\tools\pelican_quickstart.py", line 52, in <module>
    'lang': locale.getlocale()[0].split('_')[0],
AttributeError: 'NoneType' object has no attribute 'split'




Discussion:
Perhaps related to c361246, which was merged via #1972 and was meant to address #1971.

@nstinus: Any thoughts on this?

See also https://docs.python.org/2/library/locale.html, https://bugs.python.org/issue6203 and https://bugs.python.org/issue12699.
In other words: `locale.getlocale()` returns `(None, None)`. See below:

> (Pelican) D:\Documents\Pelican>python
> Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016, 15:24:40) [MSC v.1500 64 bit (
> AMD64)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> 
> > > import locale
> > > locale.getlocale()
> > > (None, None)
> > > locale.getdefaultlocale()
> > > ('es_AR', 'cp1252')
> > > locale.setlocale(locale.LC_ALL, '');
> > > 'Spanish_Argentina.1252'
> > > locale.getlocale()
> > > ('Spanish_Argentina', '1252')


Resolving patch:
diff --git a/pelican/tools/pelican_quickstart.py b/pelican/tools/pelican_quickstart.py
--- a/pelican/tools/pelican_quickstart.py
+++ b/pelican/tools/pelican_quickstart.py
@@ -21,6 +21,8 @@
 
 from pelican import __version__
 
+if (sys.version_info.major == 2):
+    locale.setlocale(locale.LC_ALL, '')
 
 _TEMPLATES_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                               "templates")


Test patch:
Repository: getpelican/pelican

Issue:
pelican-import output directory confusing name
The pelican output directory default name is ``output`` for html generated files, but the pelican-import output directory default name is ``output`` for content source files.

This could be very confusing for beginers. I think that a sane pelican-import output directory default name should be ``content``, as it's the pelican default name for content source files directory.
pelican-import output directory confusing name
The pelican output directory default name is ``output`` for html generated files, but the pelican-import output directory default name is ``output`` for content source files.

This could be very confusing for beginers. I think that a sane pelican-import output directory default name should be ``content``, as it's the pelican default name for content source files directory.


Discussion:

Resolving patch:
diff --git a/pelican/tools/pelican_import.py b/pelican/tools/pelican_import.py
--- a/pelican/tools/pelican_import.py
+++ b/pelican/tools/pelican_import.py
@@ -790,7 +790,7 @@ def main():
         '--feed', action='store_true', dest='feed',
         help='Feed to parse')
     parser.add_argument(
-        '-o', '--output', dest='output', default='output',
+        '-o', '--output', dest='output', default='content',
         help='Output path')
     parser.add_argument(
         '-m', '--markup', dest='markup', default='rst',


Test patch:
Repository: getpelican/pelican

Issue:
folder syslink are ignored inside ```theme/static```
how to reproduce 

```
$ cd ~/blog/theme/yourtheme/static
$ mkdir testfolder # folders are copied
$ ln -s ../screenshot.png . # linked files are copied
$ ln -s ../templates . # syslinked folders arent copied. Any folder should do for testing purposes
$ cd ~/blog
$ make html
$ ls -l output/theme/
 testfolder
 screenshot.png
```
folder syslink are ignored inside ```theme/static```
how to reproduce 

```
$ cd ~/blog/theme/yourtheme/static
$ mkdir testfolder # folders are copied
$ ln -s ../screenshot.png . # linked files are copied
$ ln -s ../templates . # syslinked folders arent copied. Any folder should do for testing purposes
$ cd ~/blog
$ make html
$ ls -l output/theme/
 testfolder
 screenshot.png
```


Discussion:

Resolving patch:
diff --git a/pelican/utils.py b/pelican/utils.py
--- a/pelican/utils.py
+++ b/pelican/utils.py
@@ -360,7 +360,7 @@ def walk_error(err):
                            source_, destination_)
             return
 
-        for src_dir, subdirs, others in os.walk(source_):
+        for src_dir, subdirs, others in os.walk(source_, followlinks=True):
             dst_dir = os.path.join(destination_,
                                    os.path.relpath(src_dir, source_))
 


Test patch:
Repository: getpelican/pelican

Issue:
Unclear error message running pelican.server 
Hello,

I recently upgraded from 3.7.1 to master. After building my site, I tried to run the server via `python -m pelican.server`, as previously. I got a new message:

    server.py: error: the following arguments are required: path

Ok, cool. I don't have to cd into output/ any more to run the server. Running `python -m pelican.server outupt/`:

    TypeError: __init__() missing 1 required positional argument: 'RequestHandlerClass'

That is... less than helpful. Googling doesn't have any pertinent info. After a little digging, I found the master branch docs already specify the new `pelican --listen` and that resolved it.

It took me a little bit to figure out what was going on - I wasn't expecting the command line UI to change on a minor version, and the message ended up being totally unrelated to what had actually happened.

I think it would be helpful for people upgrading from previous versions to give a clearer error message, maybe 'The pelican server should be run via `pelican --listen`'.

Thanks for all the work so far!


Discussion:
Hi Ryan. I'm all for helpful error messages, so thanks for raising this issue. Thoughts in no particular order:

* When released, the Pelican 3.8 announcement post will include "how to upgrade" info, as usual.
* Rather than Google, solution might've been more easily found via the [dev docs](http://docs.getpelican.com/en/latest/) or the [closed milestone PRs](https://github.com/getpelican/pelican/milestone/12?closed=1).
* This CLI UI change will be introduced in version 3.8, which from my perspective isn't minor.

But as I said, I'm all for helpful error messages. Would you like to help us implement a better error message for this condition, in order to help upgraders who haven't read the announcement post? (cc:  @josch @Lucas-C)

Resolving patch:
diff --git a/pelican/server.py b/pelican/server.py
--- a/pelican/server.py
+++ b/pelican/server.py
@@ -131,6 +131,11 @@ def __init__(self, base_path, *args, **kwargs):
         logging.error("Could not listen on port %s, server %s.",
                       args.port, args.server)
         sys.exit(getattr(e, 'exitcode', 1))
+    except TypeError as e:
+        logging.error("'python -m pelican.server' is deprecated. The " +
+                      "Pelican development server should be run via " +
+                      "'pelican --listen'")
+        sys.exit(getattr(e, 'exitcode', 1))
 
     logging.info("Serving at port %s, server %s.",
                  args.port, args.server)


Test patch:
Repository: getpelican/pelican

Issue:
mtime issue on Debian stretch make files copy quasi systematic even if STATIC_CHECK_IF_MODIFIED set to True
Issue on commit 9e526a825ee308c9e982bf0eca427ea4fdfc0f8d.

> python copy instruction doesn't preserve mtime under Debian/stretch (up to date).

This results in lot of files are copied to output even if not changed.

**Proposed solution in pelican/pelican/generators.py, line 823:**
        #return s_mtime > d_mtime
        return s_mtime - d_mtime > 0.000001

Exemples from stat:

| Source | Output (created by copy) |
| ----------------------------------- | ----------------------------------- |
| 2018-09-26 16:16:23.298790930 +0200 | 2018-09-26 16:16:23.298790000 +0200 |
| 2018-09-26 16:00:53.379527955 +0200 | 2018-09-26 16:00:53.379528000 +0200 |
| 2018-09-26 16:05:24.019213477 +0200 | 2018-09-26 16:05:24.019213000 +0200 |
| 2018-09-26 16:14:52.660719249 +0200 | 2018-09-26 16:14:52.660719000 +0200 |
| 2018-09-26 16:05:53.790765421 +0200 | 2018-09-26 16:05:53.790765000 +0200 |
| 2018-09-26 17:00:02.930290005 +0200 | 2018-09-26 17:00:02.930289000 +0200 |
| 2018-09-26 17:01:30.525954070 +0200 | 2018-09-26 17:01:30.525954000 +0200 |
| 2018-09-26 15:58:24.850144752 +0200 | 2018-09-26 15:58:24.850144000 +0200 |

After this patch, my pelican ran from 300s to ... less than one second...


Discussion:
Well, that's annoying. Looks like a truncation issue. 

Your solution sounds reasonable to me. Want to turn it into a PR :) ?

Resolving patch:
diff --git a/pelican/generators.py b/pelican/generators.py
--- a/pelican/generators.py
+++ b/pelican/generators.py
@@ -820,7 +820,7 @@ def _source_is_newer(self, staticfile):
         save_as = os.path.join(self.output_path, staticfile.save_as)
         s_mtime = os.path.getmtime(source_path)
         d_mtime = os.path.getmtime(save_as)
-        return s_mtime > d_mtime
+        return s_mtime - d_mtime > 0.000001
 
     def _link_or_copy_staticfile(self, sc):
         if self.settings['STATIC_CREATE_LINKS']:


Test patch:
Repository: getpelican/pelican

Issue:
Dump variables on debug
Having a double verbose debug which dump variables both CONF variables and variables used in templates would help a lot while debugging :)


Discussion:
See #1984 
@voidplayer if #1984 resolves this, could you close this issue, please?

Resolving patch:
diff --git a/pelican/__init__.py b/pelican/__init__.py
--- a/pelican/__init__.py
+++ b/pelican/__init__.py
@@ -7,6 +7,7 @@
 import logging
 import multiprocessing
 import os
+import pprint
 import re
 import sys
 import time
@@ -269,6 +270,32 @@ def get_writer(self):
             return writer(self.output_path, settings=self.settings)
 
 
+class PrintSettings(argparse.Action):
+    def __call__(self, parser, namespace, values, option_string):
+        instance, settings = get_instance(namespace)
+
+        if values:
+            # One or more arguments provided, so only print those settings
+            for setting in values:
+                if setting in settings:
+                    # Only add newline between setting name and value if dict
+                    if isinstance(settings[setting], dict):
+                        setting_format = '\n{}:\n{}'
+                    else:
+                        setting_format = '\n{}: {}'
+                    print(setting_format.format(
+                        setting,
+                        pprint.pformat(settings[setting])))
+                else:
+                    print('\n{} is not a recognized setting.'.format(setting))
+                    break
+        else:
+            # No argument was given to --print-settings, so print all settings
+            pprint.pprint(settings)
+
+        parser.exit()
+
+
 def parse_arguments():
     parser = argparse.ArgumentParser(
         description='A tool to generate a static blog, '
@@ -319,6 +346,12 @@ def parse_arguments():
                         help='Relaunch pelican each time a modification occurs'
                         ' on the content files.')
 
+    parser.add_argument('--print-settings', dest='print_settings', nargs='*',
+                        action=PrintSettings, metavar='SETTING_NAME',
+                        help='Print current configuration settings and exit. '
+                        'Append one or more setting name arguments to see the '
+                        'values for specific settings only.')
+
     parser.add_argument('--relative-urls', dest='relative_paths',
                         action='store_true',
                         help='Use relative urls in output, '
@@ -527,6 +560,7 @@ def main():
 
     try:
         pelican, settings = get_instance(args)
+
         readers = Readers(settings)
         reader_descs = sorted(set(['%s (%s)' %
                                    (type(r).__name__,


Test patch:
Repository: getpelican/pelican

Issue:
Category/Tag/Author slugs are not settable
URLWrapper objects have a setter for their 'slug' property, but all of the concrete URLWrapper subclasses override the _getter_ for 'slug', which, because of the way Python's property accessors work, makes the setter inaccessible.  This breaks the 'category_meta' plugin and probably other things as well.


Discussion:
Status: @zackw submitted PR #2243, which needs additional work before it can be merged.

Resolving patch:
diff --git a/pelican/urlwrappers.py b/pelican/urlwrappers.py
--- a/pelican/urlwrappers.py
+++ b/pelican/urlwrappers.py
@@ -36,9 +36,17 @@ def name(self, name):
     @property
     def slug(self):
         if self._slug is None:
-            self._slug = slugify(
-                self.name,
-                regex_subs=self.settings.get('SLUG_REGEX_SUBSTITUTIONS', []))
+            class_key = '{}_REGEX_SUBSTITUTIONS'.format(
+                self.__class__.__name__.upper())
+            if class_key in self.settings:
+                self._slug = slugify(
+                    self.name,
+                    regex_subs=self.settings[class_key])
+            else:
+                self._slug = slugify(
+                    self.name,
+                    regex_subs=self.settings.get(
+                        'SLUG_REGEX_SUBSTITUTIONS', []))
         return self._slug
 
     @slug.setter
@@ -113,39 +121,13 @@ def _from_settings(self, key, get_page_name=False):
 
 
 class Category(URLWrapper):
-    @property
-    def slug(self):
-        if self._slug is None:
-            if 'CATEGORY_REGEX_SUBSTITUTIONS' in self.settings:
-                subs = self.settings['CATEGORY_REGEX_SUBSTITUTIONS']
-            else:
-                subs = self.settings.get('SLUG_REGEX_SUBSTITUTIONS', [])
-            self._slug = slugify(self.name, regex_subs=subs)
-        return self._slug
+    pass
 
 
 class Tag(URLWrapper):
     def __init__(self, name, *args, **kwargs):
         super(Tag, self).__init__(name.strip(), *args, **kwargs)
 
-    @property
-    def slug(self):
-        if self._slug is None:
-            if 'TAG_REGEX_SUBSTITUTIONS' in self.settings:
-                subs = self.settings['TAG_REGEX_SUBSTITUTIONS']
-            else:
-                subs = self.settings.get('SLUG_REGEX_SUBSTITUTIONS', [])
-            self._slug = slugify(self.name, regex_subs=subs)
-        return self._slug
-
 
 class Author(URLWrapper):
-    @property
-    def slug(self):
-        if self._slug is None:
-            if 'AUTHOR_REGEX_SUBSTITUTIONS' in self.settings:
-                subs = self.settings['AUTHOR_REGEX_SUBSTITUTIONS']
-            else:
-                subs = self.settings.get('SLUG_REGEX_SUBSTITUTIONS', [])
-            self._slug = slugify(self.name, regex_subs=subs)
-        return self._slug
+    pass


Test patch: